Destri2000/Predict_Maternal_Health_Classification
0
1import streamlit as st2import pandas as pd3import matplotlib.pyplot as plt4import seaborn as sns5from PIL import Image6 7st.set_page_config(8 page_title = 'Homepage'9)10 11def run():12 #membuat judul13 st.title('Maternal Health')14 15 #tambahkan gambar16 image_homepage = Image.open('image.jpg')17 st.image(image_homepage, caption = 'Pregnant Woman')18 19 20 #bikin garis pemisah21 st.markdown('---')22 st.write("Maternal health is a crucial aspect of public health as it directly affects the wellbeing of both mother and child. Despite advances in medical science, maternal mortality remains a significant problem in many countries, particularly in developing nations.")23 st.write("Identifying high-risk pregnancies is a critical step in ensuring maternal and fetal health, but it can be a challenging task due to the complexity and variability of the factors involved. Maternal health risk during pregnancy refers to the likelihood of a woman experiencing adverse health outcomes during pregnancy or childbirth")24 st.write("The maternal health risk dataset utilized in this study was acquired from kaggle (https://www.kaggle.com/datasets/csafrit2/maternal-health-risk-data). The data was originally collected from different hospitals, community clinics and maternal health care centers from the rural areas of Bangladesh. The dataset contained six predictive variables in pregnancy; Age (in years), Systolic Blood Pressure (in mmHg), Diastolic Blood Pressure (in mmHg), Blood Sugar (in mmol/L), Body Temperature (in degrees Fahrenheit) and Heart Rate (in beats per minute). All of which were numerical variables. A categorical target variable, Risk Level, was present in three possible classes; high risk, mid risk and low risk. These consequently totaled 7 variables in the whole dataset. There were 1,014 instances in the dataset and 406 samples")25 26 st.markdown('---')27 28 df = pd.read_csv('data.csv')29 30 column_name = {'Age': 'Age',31 'SystolicBP': 'Systolic Blood Preasure',32 'DiastolicBP': 'Diastolic Blood Preasure',33 'BS': 'Blood Sugar',34 'BodyTemp': 'Body Temprature',35 'HeartRate' : 'Heart Rate'}36 37 st.write('## Health Factors')38 option = st.selectbox('Select Column: ', list(column_name.values()))39 selected_column = [key for key, value in column_name.items() if value == option][0]40 value_counts = df[selected_column].value_counts()41 fig = plt.figure(figsize=(15,5))42 sns.barplot(x=value_counts.index, y=value_counts.values)43 plt.xlabel(option)44 plt.ylabel('Frequency')45 st.pyplot(fig)46 47 st.markdown('---')48 49 st.write('## Visualization of Health Factors on the Level of Pregnancy Risk')50 51 st.write('### Age Factors on the Level of Pregnancy Risk')52 plot_age = Image.open('age.jpg')53 st.image(plot_age)54 st.write("Probability of pregnancy risk based on age:")55 st.markdown("- The probability of women having a low and medium risk of pregnancy is when they are 20 years old with a higher probability of experiencing a low risk of pregnancy at that age.")56 st.markdown("- The probability that women have a high risk of pregnancy is when they are over 37 years old.")57 st.text(" ")58 st.text(" ")59 60 st.write('### Systolic pressure Factors on the Level of Pregnancy Risk')61 plot_sys = Image.open('sys.jpg')62 st.image(plot_sys)63 st.write("Probability of pregnancy risk based on Systolic pressure:")64 st.markdown("- The probability that a woman has a low and medium risk of pregnancy is when the systolic pressure is 120.")65 st.markdown("- The probability that a woman has a high risk of pregnancy is when the systolic pressure is more than 135 with the highest probability at a systolic pressure of 142.")66 st.text(" ")67 st.text(" ")68 69 st.write('### Diastolic pressure Factors on the Level of Pregnancy Risk')70 plot_dys = Image.open('dys.jpg')71 st.image(plot_dys)72 st.write("Probability of pregnancy risk based on Diastolic pressure:")73 st.markdown("- The probability that a woman has a low and medium risk of pregnancy is when the diastolic pressure is 80.")74 st.markdown("- The probability that a woman has a high risk of pregnancy is when the diastolic pressure is 88 with the highest probability at a diastolic pressure of 100.")75 st.text(" ")76 77 st.write('### Blood Sugar Factors on the Level of Pregnancy Risk')78 plot_bs = Image.open('bs.jpg')79 st.image(plot_bs)80 st.write("Probability of pregnancy risk based on blood sugar levels:")81 st.markdown("- The probability that a woman has a low and medium risk of pregnancy is when the blood sugar level is 7.")82 st.markdown("- The probability that a woman has a high risk of pregnancy is when the blood sugar level is more than 9.")83 st.text(" ")84 st.text(" ")85 86 st.write('### Heart Rate Factors on the Level of Pregnancy Risk')87 plot_heartrate = Image.open('heartrate.jpg')88 st.image(plot_heartrate)89 st.write("Probability of pregnancy risk based on heart rate:")90 st.markdown("- The probability that a woman has a low and medium risk of pregnancy is when her heart rate is 70-80.")91 st.markdown("- The probability that a woman has a high risk of pregnancy is when the blood sugar level is more than 81 with the highest probability at 90.")92 st.text(" ")93 st.text(" ")94 95 st.write('### Body temperature Factors on the Level of Pregnancy Risk')96 plot_temp = Image.open('temp.jpg')97 st.image(plot_temp)98 st.write("Body temperature does not have a significant effect on the risk of pregnancy")99 st.text(" ")100 101 st.markdown('---')102 st.write('## Conclusions and Recommendations')103 st.write('Age, systolic and diastolic blood pressure, blood glucose levels, and heart rate are factors that significantly influence the risk during pregnancy. The higher these factors, the greater the probability that women are at a high risk during pregnancy. Meanwhile, body temperature does not affect the risk of pregnancy.')104 st.write("Before planning to have a child, it is advisable to align with the mother's age. The optimal reproductive age is between 20-35 years. Regular health examinations and monitoring before pregnancy are also crucial for detecting potential issues. Maintaining a balanced diet and monitoring blood glucose, blood pressure, and heart rate are mandatory during pregnancy.")105if __name__ == '__main__':106 run()