File size: 1,437 Bytes
5739f5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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.")