File size: 1,383 Bytes
477d5dc | 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 | 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() |