-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheart disease.py
44 lines (32 loc) · 1.2 KB
/
heart disease.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
44
# -*- coding: utf-8 -*-
import numpy as np
import pickle
from flask import Flask, request, render_template
# Load ML model
model = pickle.load(open('model.pkl', 'rb'))
# Create application
app = Flask(__name__)
# Bind home function to URL
@app.route('/')
def home():
return render_template('Heart Disease Classifier.html')
# Bind predict function to URL
@app.route('/predict', methods=['POST'])
def predict():
# Put all form entries values in a list
features = [float(i) for i in request.form.values()]
# Convert features to array
array_features = [np.array(features)]
# Predict features
prediction = model.predict(array_features)
output = prediction
# Check the output values and retrive the result with html tag based on the value
if output == 1:
return render_template('Heart Disease Classifier.html',
result='The patient is not likely to have heart disease!')
else:
return render_template('Heart Disease Classifier.html',
result='The patient is likely to have heart disease!')
if __name__ == '__main__':
# Run the application
app.run()