-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
43 lines (34 loc) · 1.46 KB
/
app.py
File metadata and controls
43 lines (34 loc) · 1.46 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
import numpy as np
from flask import Flask, request, jsonify, render_template
import pickle
from sklearn.preprocessing import LabelEncoder, MinMaxScaler
import pandas as pd
app = Flask(__name__)
model = pickle.load(open('model_rf.pkl','rb'))
scaler = pickle.load(open('scaler.pkl','rb'))
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict',methods=['POST'])
def predict():
one = ['yes', 'present', 'good', 'normal', 'Yes', 'Present', 'Good', 'Normal', 'YES', 'PRESENT', 'GOOD', 'NORMAL']
zero = ['no', 'notpresent', 'not present', 'poor', 'abnormal', 'No', 'Notpresent', 'NotPresent', 'Not Present', 'Poor', 'Abnormal', 'AbNormal', 'NO', 'NOTPRESENT', 'NOT PRESENT', 'POOR', 'ABNORMAL']
int_features = []
for i in request.form.values():
if i in one:
int_features.append(1.0)
elif i in zero:
int_features.append(0.0)
else:
int_features.append(float(i))
final_features = [np.array(int_features)]
final_features = scaler.transform(final_features)
prediction = model.predict(final_features)
output = prediction
if output == [0]:
output = "Kidney Disease Not Detected"
elif output == [1]:
output = "Kidney Disease Detected"
return render_template('index.html', prediction_text='Diagnosis Result: {}'.format(output))
if __name__ == "__main__":
app.run(debug=True)