-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
60 lines (51 loc) · 1.61 KB
/
Copy pathapp.py
File metadata and controls
60 lines (51 loc) · 1.61 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
Streamlit App for Diabetes Prediction
"""
# =========================
# Import Libraries
# =========================
import streamlit as st
import numpy as np
from keras.models import load_model
# =========================
# Load Model
# =========================
model = load_model("diabetes_model.h5")
# =========================
# Page Config
# =========================
st.set_page_config(page_title="Diabetes Prediction", layout="centered")
# =========================
# Title
# =========================
st.title("🩺 Diabetes Prediction App")
st.write("Enter patient details to predict diabetes")
# =========================
# Input Fields
# =========================
pregnancies = st.number_input("Pregnancies", min_value=0.0)
glucose = st.number_input("Glucose Level", min_value=0.0)
blood_pressure = st.number_input("Blood Pressure", min_value=0.0)
skin_thickness = st.number_input("Skin Thickness", min_value=0.0)
insulin = st.number_input("Insulin Level", min_value=0.0)
bmi = st.number_input("BMI", min_value=0.0)
pedigree = st.number_input("Diabetes Pedigree Function", min_value=0.0)
age = st.number_input("Age", min_value=0.0)
# =========================
# Predict Button
# =========================
if st.button("Predict"):
# Convert input to numpy array
input_data = np.array([[
pregnancies, glucose, blood_pressure,
skin_thickness, insulin, bmi,
pedigree, age
]])
# Prediction
prediction = model.predict(input_data)
result = int(prediction[0][0] > 0.5)
# Output
if result == 1:
st.error("⚠️ Diabetic")
else:
st.success("✅ Not Diabetic")