Jekyll2000's picture
Create app.py
5739f5d verified
raw
history blame
1.44 kB
import pickle
import streamlit as st
# Load the model
with open("BMI_Model.pkl", "rb") as f:
model_data = pickle.load(f)
def conditional_prediction(Gender, Height, Weight):
Gen = 0
if Gender == "Male":
Gen = 1
elif Gender == "Female":
Gen = 0
Height = float(Height)
Weight = float(Weight)
result = model_data.predict([[Gen, Height, Weight]])
if result[0] == 0:
final_result = "You have an Extremely Weak Body Condition"
elif result[0] == 1:
final_result = "You have a Weak Body Condition"
elif result[0] == 2:
final_result = "You have a Normal Body Condition"
elif result[0] == 3:
final_result = "You have Estimated Overweight"
elif result[0] == 4:
final_result = "You have Estimated Obesity"
elif result[0] == 5:
final_result = "You seem to have Extreme Obesity"
return final_result, result[0]
# Streamlit UI
st.title("BMI Condition Estimator")
# Input fields
Gender = st.radio("Gender", ["Male", "Female"])
Height = st.text_input("Enter Your Height in cm")
Weight = st.text_input("Enter Your Weight in KG")
if st.button("Predict"):
if Height and Weight:
condition, index = conditional_prediction(Gender, Height, Weight)
st.write(f"Your Estimated Condition: {condition}")
st.write(f"Index: {index}")
else:
st.write("Please enter both Height and Weight.")