-
Notifications
You must be signed in to change notification settings - Fork 18
/
app.py
42 lines (33 loc) · 1.03 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
"""
A ML APPlication which predicts the profit of a StartUp based on certain features.
"""
import pickle
import numpy as np
import pandas as pd
from flask import Flask, request, render_template
APP = Flask(__name__,template_folder='templates')
MODEL = pickle.load(open('model.pkl', 'rb'))
@APP.route('/')
def home():
'''
Rendering Home Page
'''
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&D Spend', 'Administration', 'Marketing Spend', '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(host='0.0.0.0',port=8080)