File size: 1,725 Bytes
07e8c5e 4a591de 07e8c5e 4a591de 07e8c5e 0c18d60 07e8c5e 3a9c832 0938142 07e8c5e 0c18d60 07e8c5e fa7d26f 0c18d60 0046f91 07e8c5e 4a591de 07e8c5e 4a591de 07e8c5e 4a591de 07e8c5e 4a591de 07e8c5e 4a591de 07e8c5e 4a591de 07e8c5e 4a591de 07e8c5e 4a591de 3a9c832 |
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 54 55 56 57 58 |
import streamlit as st
from code.DiseaseModel import DiseaseModel
from code.helper import prepare_symptoms_array
# Create disease class and load ML model
disease_model = DiseaseModel()
disease_model.load_xgboost('model/xgboost_model.json')
# Set page width to wide
st.set_page_config(layout='wide')
# Custom CSS for background color and text color
st.markdown(
"""
<style>
.stApp {
background-color: #efefef !important;
color: black !important;
}
h1, h2, h3, h4, h5, h6, p, div, span, label {
color: black !important;
}
button, .stButton>button {
color: black !important;
}
header {display: none !important;}
</style>
""",
unsafe_allow_html=True
)
# Create sidebar
st.sidebar.markdown('# The Health AI ')
st.sidebar.markdown("This web app uses a machine learning model to predict diseases based on a set of symptoms using Scikit-learn, Python and Streamlit.")
st.sidebar.markdown("Author: S N V S KOMAL")
# Title
st.write('# Symptoms to Disease Prediction')
symptoms = st.multiselect('What are your symptoms?', options=disease_model.all_symptoms)
X = prepare_symptoms_array(symptoms)
# Trigger XGBoost model
if st.button('Predict'):
# Run the model with the python script
prediction, prob = disease_model.predict(X)
st.write(f'## Disease: {prediction} with {prob*100:.2f}% probability')
tab1, tab2= st.tabs(["Description", "Precautions"])
with tab1:
st.write(disease_model.describe_predicted_disease())
with tab2:
precautions = disease_model.predicted_disease_precautions()
for i in range(4):
st.write(f'{i+1}. {precautions[i]}') |