-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
39 lines (32 loc) · 1.22 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
from flask import Flask, render_template, url_for, flash, redirect
import joblib
from flask import request
import numpy as np
import sklearn
app = Flask(__name__, template_folder='templates')
@app.route("/")
@app.route("/cancer")
def cancer():
return render_template("cancer.html")
def ValuePredictor(to_predict_list, size):
to_predict = np.array(to_predict_list).reshape(1,size)
if(size==5):
loaded_model = joblib.load(r'cancer_model.pkl')
result = loaded_model.predict(to_predict)
return result[0]
@app.route('/predict', methods = ["POST"])
def predict():
if request.method == "POST":
to_predict_list = request.form.to_dict()
to_predict_list = list(to_predict_list.values())
to_predict_list = list(map(float, to_predict_list))
#cancer
if(len(to_predict_list)==5):
result = ValuePredictor(to_predict_list,5)
if(int(result)==1):
prediction = "Sorry you chances of getting the disease. Please consult the doctor immediately"
else:
prediction = "No need to fear. You have no dangerous symptoms of the disease"
return(render_template("result.html", prediction_text=prediction))
if __name__ == "__main__":
app.run(debug=True)