Upload 7 files
Browse filesFiles changed (7)
- app.pyAdded+59
- calories_model.joblibAdded+3
- features.pklAdded+3
- predict-calorie-expenditure.ipynbAdded
- requirements.txtAdded+5
- sex_mapping.pklAdded+3
- submission.csvAdded
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859import streamlit as stimport pandas as pdimport joblibimport numpy as np
# Set page configurationst.set_page_config(page_title="Calories Burned Predictor", layout="centered")
# Load the model and assets@st.cache_resourcedef load_assets(): model = joblib.load('calories_model.joblib') features = joblib.load('features.pkl') # Using the manual mapping established: {'female': 1, 'male': 0} sex_mapping = {'female': 1, 'male': 0} return model, features, sex_mapping
model, expected_features, sex_mapping = load_assets()
st.title("🔥 Calorie Expenditure Predictor")st.markdown("Predict calories burned during exercise using a high-precision XGBoost model.")
# Create input formwith st.form("prediction_form"): col1, col2 = st.columns(2) with col1: sex = st.selectbox("Sex", options=["female", "male"]) age = st.number_input("Age", min_value=1, max_value=100, value=25) height = st.number_input("Height (cm)", min_value=100.0, max_value=250.0, value=170.0) weight = st.number_input("Weight (kg)", min_value=30.0, max_value=200.0, value=70.0) with col2: duration = st.number_input("Duration (min)", min_value=1.0, max_value=180.0, value=30.0) heart_rate = st.number_input("Heart Rate", min_value=40.0, max_value=220.0, value=100.0) body_temp = st.number_input("Body Temperature (°C)", min_value=35.0, max_value=42.0, value=37.0)
submit = st.form_submit_with_button("Predict Calories")
if submit: # Prepare the input dictionary input_dict = { 'Sex': sex_mapping[sex], 'Age': age, 'Height': height, 'Weight': weight, 'Duration': duration, 'Heart_Rate': heart_rate, 'Body_Temp': body_temp } # Convert to DataFrame and ensure correct feature order input_df = pd.DataFrame([input_dict]) input_df = input_df[expected_features] # Prediction prediction = model.predict(input_df) st.success(f"### Estimated Calories Burned: {prediction[0]:.2f} kcal")123version https://git-lfs.github.com/spec/v1oid sha256:44009dc88136cd17f55fb9c03c80be8f51d278517a02089fc65f94a3e75b857csize 4385005123version https://git-lfs.github.com/spec/v1oid sha256:670ed44ae6a0ae51f3072a24f0774911694ca86cbdcc2fb6a1c49c08cc19b58csize 8212345xgboostpandasnumpyjoblibstreamlit123version https://git-lfs.github.com/spec/v1oid sha256:91484661ea1159b92ef4f9d86fa6519ed7a64034d1eb9d3c5d364b39f8fb24e8size 36app.pyAdded+59
calories_model.joblibAdded+3
features.pklAdded+3
predict-calorie-expenditure.ipynbAdded
requirements.txtAdded+5
sex_mapping.pklAdded+3
submission.csvAdded