Download prediction.py from Destri2000/Predict_Maternal_Health_Classification: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/Destri2000/Predict_Maternal_Health_Classification/resolve/main/prediction.py
- Command line
-
hf download hf://spaces/Destri2000/Predict_Maternal_Health_Classification/prediction.py
-
curl -L -o prediction.py https://huggingface.co/spaces/Destri2000/Predict_Maternal_Health_Classification/resolve/main/prediction.py
1.38 kB
| import streamlit as st | |
| import pandas as pd | |
| import pickle | |
| with open('final_model.pkl', 'rb') as file_1: | |
| final_model = pickle.load(file_1) | |
| def run(): | |
| st.title('Prediction Maternal Risk') | |
| with st.form('Form information'): | |
| Age = st.slider('Age in years when pregnant', 0, 100, 0) | |
| SystolicBP = st.slider('Systolic Blood Preasure in mmHg', 0, 170, 1) | |
| DiastolicBP = st.slider('Diastolic Blood Preasure in mmHg', 0, 110, 1) | |
| BS = st.slider('Blood Glucose Level in mmol/L', 0.0, 20.0, 1.0) | |
| BodyTemp = st.slider('Body Temprature in Farenheit', 50.0, 110.0, 1.0) | |
| HeartRate = st.slider('Normal Resting Heart Rate in Beats per Minute', 0, 100, 1) | |
| #submit button | |
| submitted = st.form_submit_button("Predict") | |
| data = { | |
| 'Age' : Age, | |
| 'SystolicBP' : SystolicBP, | |
| 'DiastolicBP' : DiastolicBP, | |
| 'BS' : BS, | |
| 'BodyTemp' : BodyTemp, | |
| 'HeartRate' : HeartRate, | |
| } | |
| data = pd.DataFrame([data]) | |
| if submitted: | |
| # predict using linear reg model | |
| pred = final_model.predict(data) | |
| if pred == 0: | |
| st.write('## Prediction: Low Risk') | |
| elif pred == 1: | |
| st.write('## Prediction: Medium Risk') | |
| else : | |
| st.write('## Prediction: High Risk') | |
| if __name__ == '__main__': | |
| run() |