-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathhello.py
More file actions
48 lines (33 loc) · 1.15 KB
/
hello.py
File metadata and controls
48 lines (33 loc) · 1.15 KB
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
43
44
45
46
47
import numpy as np
from flask import Flask, request, jsonify, render_template
import pickle
import pandas as pd
from joblib import dump, load
app = Flask(__name__)
filename = "models/model.pkl"
with open(filename, 'rb') as file:
model = load(file)
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict', methods=['POST'])
def predict():
'''
For rendering results on HTML GUI
'''
X_test_new = [x.strip() for x in request.form.values()]
X_test_new[1] = float(X_test_new[1])
X_test_new[2] = float(X_test_new[2])
X_test_new[3] = float(X_test_new[3])
# final_features = [np.array(int_features)]
# X_test_new = [x for x in request.form.values()]
# # print(sgd_clf.predict(X_test_new_count))
#
ll = [X_test_new]
new_data = pd.DataFrame(ll, columns=['Gas', 'Water_content',
'viscosity','time_minutes'])
prediction = model.predict(new_data)[0]
output = round(prediction, 2)
return render_template('index.html', prediction_text='Estimated IFT = {} mN/m'.format( output))
if __name__ == "__main__":
app.run(debug=True)