File size: 1,756 Bytes
853e9d1
3fc3fa4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
import streamlit as st
import pandas as pd
import joblib
import numpy as np
import os

# Load model and scaler
MODEL_PATH = os.path.join(os.path.dirname(__file__), "model", "xgb_model.joblib")
SCALER_PATH = os.path.join(os.path.dirname(__file__), "model", "scaler.joblib")

model = joblib.load(MODEL_PATH)
scaler = joblib.load(SCALER_PATH)

st.title("Hemoglobin Level Predictor")

st.markdown(
    """
    ### Developed by Dr. Vinod Kumar Yata's research group  
    School of Allied and Healthcare Sciences, Malla Reddy University, Hyderabad, India

    ---
    ⚠️ **Warning**:  
    This is an experimental tool and should not be used for medical diagnosis.  
    Always consult a licensed healthcare provider for medical advice.
    ---
    """
)

# Input fields
age = st.number_input("Age", min_value=0, max_value=120, value=30)
gender = st.selectbox("Gender", options=["Male", "Female"])
o2_saturation = st.slider("O2 Saturation (%)", min_value=50.0, max_value=100.0, value=98.0)
bp_systolic = st.number_input("Systolic BP", min_value=50, max_value=200, value=120)
bp_diastolic = st.number_input("Diastolic BP", min_value=30, max_value=130, value=80)
respiratory_rate = st.number_input("Respiratory Rate (breaths/min)", min_value=5, max_value=60, value=18)

# Map gender to numeric
gender_num = 1 if gender == "Male" else 0

input_df = pd.DataFrame([{
    "Age": age,
    "Gender": gender_num,
    "O2_Saturation": o2_saturation,
    "BP_Systolic": bp_systolic,
    "BP_Diastolic": bp_diastolic,
    "Respiratory_Rate": respiratory_rate
}])

if st.button("Predict Hemoglobin Level"):
    input_scaled = scaler.transform(input_df)
    prediction = model.predict(input_scaled)[0]
    st.success(f"Predicted Hemoglobin Level: {prediction:.2f} g/dL")