from flask import render_template, request, Flask
import joblib
app = Flask(__name__)
model = joblib.load('dicisionTreeModel.pkl')
@app.route('/')
def index():
return render_template('Main.html')
@app.route('/predict', methods=['GET','POST'])
def predict():
if (request.method) =='POST':
age = request.form.get('age')
sysBloodPress = request.form.get('sysBloodPress')
diaBloodPress = request.form.get('diaBloodPress')
bloodGlucoseLevel = request.form.get('bloodGlucoseLevel')
bodyTemp = request.form.get('bodyTemp')
heartRate = request.form.get('heartRate')
data = [age, sysBloodPress, diaBloodPress,
bloodGlucoseLevel, bodyTemp, heartRate]
patientPredict = model.predict([data])[0]
if patientPredict < 1.5:
return render_template('Main.html', predict=f'Your Risk Level is {patientPredict}, which is Low')
elif patientPredict < 2.5:
return render_template('Main.html', predict=f'Your Risk Level is {patientPredict}, which is Medium')
else:
return render_template('Main.html', predict=f'Your Risk Level is {patientPredict}, which is High')
if __name__ == "__main__":
app.run(debug=True)