-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
31 lines (22 loc) · 725 Bytes
/
Copy pathapp.py
File metadata and controls
31 lines (22 loc) · 725 Bytes
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
from flask import Flask, render_template, request
import numpy as np
import joblib
app = Flask(__name__)
model = joblib.load("diabetes_model.pkl")
scaler = joblib.load("scaler.pkl")
@app.route("/")
def home():
return render_template("index.html")
@app.route("/predict", methods=["POST"])
def predict():
values = [float(x) for x in request.form.values()]
data = np.array([values])
data_scaled = scaler.transform(data)
prediction = model.predict(data_scaled)[0]
if prediction == 1:
result = "High Diabetes Risk ⚠️"
else:
result = "Low Diabetes Risk ✅"
return render_template("index.html", prediction_text=result)
if __name__ == "__main__":
app.run(debug=True)