Last active
June 11, 2020 19:50
-
-
Save findtharun/3ecb0c6bf32d759a7a2d2aec4cfef60e to your computer and use it in GitHub Desktop.
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
import numpy as np | |
import pandas as pd | |
from flask import Flask, request, jsonify, render_template | |
import pickle | |
app = Flask(__name__,template_folder='templates') | |
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 | |
''' | |
features = [x for x in request.form.values()] | |
final_features = [np.array(features)] | |
column_names=['R&DSpend','Administration','MarketingSpend','State'] | |
final_features=pd.DataFrame(final_features,columns=column_names) | |
prediction= model.predict(final_features) | |
temp=0.0 | |
for i in prediction: | |
for j in i: | |
temp=j | |
return render_template('index.html', prediction_text='${}'.format(temp)) | |
if __name__ == '__main__': | |
app.run(port = 5000, debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment