CoolFace
Apppublic

Destri2000/Predict_Maternal_Health_Classification

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
prediction.py46 linesDownload Raw Back to root
1import streamlit as st2import pandas as pd3import pickle 4 5with open('final_model.pkl', 'rb') as file_1: 6    final_model = pickle.load(file_1)7 8 9def run():10    st.title('Prediction Maternal Risk')11    with st.form('Form information'):12        Age = st.slider('Age in years when pregnant', 0, 100, 0)13        SystolicBP = st.slider('Systolic Blood Preasure in mmHg', 0, 170, 1)14        DiastolicBP = st.slider('Diastolic Blood Preasure in mmHg', 0, 110, 1)15        BS = st.slider('Blood Glucose Level in mmol/L', 0.0, 20.0, 1.0)16        BodyTemp = st.slider('Body Temprature in Farenheit', 50.0, 110.0, 1.0)17        HeartRate = st.slider('Normal Resting Heart Rate in Beats per Minute', 0, 100, 1)18       19        #submit button20        submitted = st.form_submit_button("Predict")21        22            23    data = {24        'Age' : Age,25        'SystolicBP' : SystolicBP,26        'DiastolicBP' : DiastolicBP,27        'BS' : BS,28        'BodyTemp' : BodyTemp,29        'HeartRate' : HeartRate,30        }31 32    data = pd.DataFrame([data])33 34    if submitted:35       # predict using linear reg model 36        pred = final_model.predict(data)37        if pred == 0:38            st.write('## Prediction: Low Risk')39        elif pred == 1:40            st.write('## Prediction: Medium Risk')41        else :42            st.write('## Prediction: High Risk')43 44 45if __name__ == '__main__':46   run()