Spaces:
Runtime error
Runtime error
| # app.py | |
| import streamlit as st | |
| import pandas as pd | |
| from tensorflow.keras.models import load_model | |
| # ----------------------------- | |
| # 1️⃣ Model Yükleme | |
| # ----------------------------- | |
| model = load_model("src/model.keras") | |
| # ----------------------------- | |
| # 2️⃣ Streamlit Başlığı | |
| # ----------------------------- | |
| st.title("Diabetes Prediction App") | |
| st.write("Input your health data to predict diabetes probability.") | |
| # ----------------------------- | |
| # 3️⃣ Kullanıcı Sayısal Girdileri | |
| # ----------------------------- | |
| age = st.number_input("Age", min_value=1, max_value=120, value=30) | |
| bmi = st.number_input("BMI", min_value=10.0, max_value=60.0, value=25.0) | |
| systolic_bp = st.number_input("Systolic BP", min_value=80, max_value=200, value=120) | |
| diastolic_bp = st.number_input("Diastolic BP", min_value=50, max_value=150, value=80) | |
| physical_activity = st.number_input("Physical Activity (minutes/week)", min_value=0, max_value=1000, value=60) | |
| screen_time = st.number_input("Screen Time (hours/day)", min_value=0, max_value=24, value=4) | |
| ldl = st.number_input("LDL Cholesterol", min_value=50, max_value=300, value=120) | |
| hdl = st.number_input("HDL Cholesterol", min_value=20, max_value=100, value=50) | |
| # ----------------------------- | |
| # 4️⃣ Input DataFrame | |
| # ----------------------------- | |
| input_df = pd.DataFrame([[ | |
| age, bmi, systolic_bp, diastolic_bp, physical_activity, screen_time, ldl, hdl | |
| ]], | |
| columns=[ | |
| 'age','bmi','systolic_bp','diastolic_bp','physical_activity_minutes_per_week', | |
| 'screen_time_hours_per_day','ldl_cholesterol','hdl_cholesterol' | |
| ]) | |
| # ----------------------------- | |
| # 5️⃣ Opsiyonel Feature Engineering | |
| # ----------------------------- | |
| input_df['cholesterol_ratio'] = input_df['ldl_cholesterol'] / (input_df['hdl_cholesterol'] + 1e-5) | |
| input_df['activity_screen_ratio'] = input_df['physical_activity_minutes_per_week'] / (input_df['screen_time_hours_per_day'] + 1) | |
| # ----------------------------- | |
| # 6️⃣ Tahmin | |
| # ----------------------------- | |
| prediction = model.predict(input_df)[0][0] | |
| # ----------------------------- | |
| # 7️⃣ Tahmin Sonucu Gösterimi | |
| # ----------------------------- | |
| st.subheader("Prediction") | |
| st.write(f"Predicted probability of diabetes: **{prediction:.2f}**") | |