Spaces:
Runtime error
Runtime error
Update src/app.py
Browse files- src/app.py +25 -19
src/app.py
CHANGED
|
@@ -3,39 +3,45 @@ import pandas as pd
|
|
| 3 |
import numpy as np
|
| 4 |
import joblib
|
| 5 |
|
| 6 |
-
# Load model
|
| 7 |
model = joblib.load("src/final_model.pkl")
|
| 8 |
features = joblib.load("src/model_features.pkl")
|
| 9 |
|
| 10 |
st.title("🔥 Calorie Burn Predictor")
|
| 11 |
|
| 12 |
-
# Inputs
|
| 13 |
sex = st.selectbox("Sex", ["male", "female"])
|
| 14 |
age = st.number_input("Age", 10, 100, 25)
|
| 15 |
height = st.number_input("Height (cm)", 100.0, 220.0, 170.0)
|
| 16 |
weight = st.number_input("Weight (kg)", 30.0, 200.0, 70.0)
|
| 17 |
-
duration = st.number_input("
|
| 18 |
heart_rate = st.number_input("Heart Rate", 50.0, 200.0, 100.0)
|
| 19 |
-
body_temp = st.number_input("Body
|
| 20 |
|
| 21 |
# Feature engineering
|
| 22 |
bmi = weight / ((height/100)**2)
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
if st.button("Predict Calories"):
|
| 40 |
prediction = model.predict(input_df)
|
| 41 |
-
st.success(f"🔥 Estimated Calories Burned: {prediction[0]:.2f}")
|
|
|
|
| 3 |
import numpy as np
|
| 4 |
import joblib
|
| 5 |
|
| 6 |
+
# Load model and features
|
| 7 |
model = joblib.load("src/final_model.pkl")
|
| 8 |
features = joblib.load("src/model_features.pkl")
|
| 9 |
|
| 10 |
st.title("🔥 Calorie Burn Predictor")
|
| 11 |
|
|
|
|
| 12 |
sex = st.selectbox("Sex", ["male", "female"])
|
| 13 |
age = st.number_input("Age", 10, 100, 25)
|
| 14 |
height = st.number_input("Height (cm)", 100.0, 220.0, 170.0)
|
| 15 |
weight = st.number_input("Weight (kg)", 30.0, 200.0, 70.0)
|
| 16 |
+
duration = st.number_input("Duration (min)", 1.0, 300.0, 30.0)
|
| 17 |
heart_rate = st.number_input("Heart Rate", 50.0, 200.0, 100.0)
|
| 18 |
+
body_temp = st.number_input("Body Temp", 35.0, 42.0, 37.0)
|
| 19 |
|
| 20 |
# Feature engineering
|
| 21 |
bmi = weight / ((height/100)**2)
|
| 22 |
|
| 23 |
+
# Boş dataframe oluştur
|
| 24 |
+
input_dict = {col: 0 for col in features}
|
| 25 |
+
|
| 26 |
+
# Sayısal değerleri ekle
|
| 27 |
+
input_dict["Age"] = age
|
| 28 |
+
input_dict["Height"] = height
|
| 29 |
+
input_dict["Weight"] = weight
|
| 30 |
+
input_dict["Duration"] = duration
|
| 31 |
+
input_dict["Heart_Rate"] = heart_rate
|
| 32 |
+
input_dict["Body_Temp"] = body_temp
|
| 33 |
+
|
| 34 |
+
# BMI varsa ekle
|
| 35 |
+
if "BMI" in features:
|
| 36 |
+
input_dict["BMI"] = bmi
|
| 37 |
+
|
| 38 |
+
# Sex encoding
|
| 39 |
+
if "Sex_male" in features:
|
| 40 |
+
input_dict["Sex_male"] = 1 if sex == "male" else 0
|
| 41 |
+
|
| 42 |
+
# DataFrame oluştur
|
| 43 |
+
input_df = pd.DataFrame([input_dict])
|
| 44 |
|
| 45 |
if st.button("Predict Calories"):
|
| 46 |
prediction = model.predict(input_df)
|
| 47 |
+
st.success(f"🔥 Estimated Calories Burned: {prediction[0]:.2f}")
|