-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
44 lines (32 loc) · 1.21 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
# Importing essential libraries
from flask import Flask, render_template, request
import pickle
import numpy as np
# Load the SVC model
filename = 'model.pkl'
model = pickle.load(open(filename, 'rb'))
app = Flask(__name__)
@app.route('/')
def home():
return render_template('main.html')
@app.route('/predict', methods=['GET','POST'])
def predict():
if request.method == 'POST':
age = int(request.form['age'])
sex = request.form.get('sex')
cp = request.form.get('cp')
trestbps = int(request.form['trestbps'])
chol = int(request.form['chol'])
fbs = request.form.get('fbs')
restecg = int(request.form['restecg'])
thalach = int(request.form['thalach'])
exang = request.form.get('exang')
oldpeak = float(request.form['oldpeak'])
slope = request.form.get('slope')
ca = int(request.form['ca'])
thal = request.form.get('thal')
data = np.array([[age,sex,cp,trestbps,chol,fbs,restecg,thalach,exang,oldpeak,slope,ca,thal]])
my_prediction = model.predict(data)
return render_template('result.html', prediction=my_prediction)
if __name__ == '__main__':
app.run(debug=True)