Spaces:
Sleeping
Sleeping
Jekyll2000
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pickle
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
# Load the model
|
5 |
+
with open("BMI_Model.pkl", "rb") as f:
|
6 |
+
model_data = pickle.load(f)
|
7 |
+
|
8 |
+
def conditional_prediction(Gender, Height, Weight):
|
9 |
+
Gen = 0
|
10 |
+
if Gender == "Male":
|
11 |
+
Gen = 1
|
12 |
+
elif Gender == "Female":
|
13 |
+
Gen = 0
|
14 |
+
|
15 |
+
Height = float(Height)
|
16 |
+
Weight = float(Weight)
|
17 |
+
|
18 |
+
result = model_data.predict([[Gen, Height, Weight]])
|
19 |
+
|
20 |
+
if result[0] == 0:
|
21 |
+
final_result = "You have an Extremely Weak Body Condition"
|
22 |
+
elif result[0] == 1:
|
23 |
+
final_result = "You have a Weak Body Condition"
|
24 |
+
elif result[0] == 2:
|
25 |
+
final_result = "You have a Normal Body Condition"
|
26 |
+
elif result[0] == 3:
|
27 |
+
final_result = "You have Estimated Overweight"
|
28 |
+
elif result[0] == 4:
|
29 |
+
final_result = "You have Estimated Obesity"
|
30 |
+
elif result[0] == 5:
|
31 |
+
final_result = "You seem to have Extreme Obesity"
|
32 |
+
|
33 |
+
return final_result, result[0]
|
34 |
+
|
35 |
+
# Streamlit UI
|
36 |
+
st.title("BMI Condition Estimator")
|
37 |
+
|
38 |
+
# Input fields
|
39 |
+
Gender = st.radio("Gender", ["Male", "Female"])
|
40 |
+
Height = st.text_input("Enter Your Height in cm")
|
41 |
+
Weight = st.text_input("Enter Your Weight in KG")
|
42 |
+
|
43 |
+
if st.button("Predict"):
|
44 |
+
if Height and Weight:
|
45 |
+
condition, index = conditional_prediction(Gender, Height, Weight)
|
46 |
+
st.write(f"Your Estimated Condition: {condition}")
|
47 |
+
st.write(f"Index: {index}")
|
48 |
+
else:
|
49 |
+
st.write("Please enter both Height and Weight.")
|