-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
38 lines (28 loc) · 1.15 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
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from flask import Flask, request, render_template
import pickle
app = Flask(__name__)
model = pickle.load(open('linear_regression_model.pkl','rb'))
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict',methods=['POST'])
def predict():
input_features = [float(x) for x in request.form.values()]
features_value = [np.array(input_features)]
features_name = [ "age", "trestbps","chol","thalach", "oldpeak", "sex_0",
" sex_1", "cp_0", "cp_1", "cp_2", "cp_3"," fbs_0",
"restecg_0","restecg_1","restecg_2","exang_0","exang_1",
"slope_0","slope_1","slope_2","ca_0","ca_1","ca_2","thal_1",
"thal_2","thal_3"]
df = pd.DataFrame(features_value, columns=features_name)
output = model.predict(df)
if output == 1:
res_val = "** heart disease **"
else:
res_val = "no heart disease "
return render_template('index.html', prediction_text='Patient has {}'.format(res_val))
if __name__ == "__main__":
app.run()