-
-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #430 from anishamurmu13/solar
Solar Radiation Prediction
- Loading branch information
Showing
14 changed files
with
69,154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: gunicorn app:app |
32,687 changes: 32,687 additions & 0 deletions
32,687
Solar Radiation Prediction/Backend/SolarPrediction.csv
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import numpy as np | ||
from flask import Flask, request, jsonify,render_template | ||
import pickle | ||
|
||
app = Flask(__name__) | ||
model = pickle.load(open('model.pkl', 'rb')) | ||
|
||
@app.route('/') | ||
def home(): | ||
return render_template('index.html') | ||
|
||
@app.route('/predict',methods=['POST']) | ||
def predict(): | ||
''' | ||
For rendering results on HTML GUI | ||
''' | ||
int_features = [float(x) for x in request.form.values()] | ||
final_features = [np.array(int_features)] | ||
prediction = model.predict(final_features) | ||
|
||
output = int(np.round(prediction[0], 2)) | ||
|
||
return render_template('index.html', prediction_text='Solar Radiation is {} W/m²'.format(output)) | ||
|
||
@app.route('/predict_api',methods=['POST']) | ||
def predict_api(): | ||
''' | ||
For direct API calls trought request | ||
''' | ||
data = request.get_json(force=True) | ||
prediction = model.predict([np.array(list(data.values()))]) | ||
|
||
output = prediction[0] | ||
return jsonify(output) | ||
|
||
if __name__ == "__main__": | ||
app.run(debug=True) |
Binary file not shown.
Oops, something went wrong.