Skip to content

Commit

Permalink
Merge pull request #430 from anishamurmu13/solar
Browse files Browse the repository at this point in the history
Solar Radiation Prediction
  • Loading branch information
prathimacode-hub authored Jul 11, 2021
2 parents 2120657 + 314b6e5 commit d779a40
Show file tree
Hide file tree
Showing 14 changed files with 69,154 additions and 0 deletions.
1 change: 1 addition & 0 deletions Solar Radiation Prediction/Backend/Procfile
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 Solar Radiation Prediction/Backend/SolarPrediction.csv

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions Solar Radiation Prediction/Backend/app.py
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 added Solar Radiation Prediction/Backend/model.pkl
Binary file not shown.
Loading

0 comments on commit d779a40

Please sign in to comment.