-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.py
43 lines (32 loc) · 1.23 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
43
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import numpy as np
import pandas as pd
from flask import Flask, request, jsonify, render_template
import pickle
# In[2]:
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=['HR','O2Sat','Temp','SBP','MAP','DBP','Resp','EtCO2','BaseExcess','HCO3','FiO2','pH','PaCO2','SaO2','AST','BUN','Alkalinephos',
'Calcium','Chloride','Creatinine','Bilirubin_direct','Glucose','Lactate','Magnesium','Phosphate','Potassium','Bilirubin_total','TroponinI','Hct','Hgb','PTT','WBC','Fibrinogen','Platelets','Age','Gender','Unit1','Unit2','HospAdmTime','ICULOS']
final_features=pd.DataFrame(final_features,columns=column_names)
prediction= model.predict(final_features)
a=""
if prediction[0]==0:
a+="NO SEPSIS"
else:
a+="SEPSIS"
return render_template('index.html', prediction_text='{}'.format(a))
if __name__ == '__main__':
app.run()