|
import streamlit as st |
|
from code.DiseaseModel import DiseaseModel |
|
from code.helper import prepare_symptoms_array |
|
|
|
|
|
disease_model = DiseaseModel() |
|
disease_model.load_xgboost('model/xgboost_model.json') |
|
|
|
|
|
st.set_page_config(layout='wide') |
|
|
|
|
|
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 |
|
) |
|
|
|
|
|
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") |
|
|
|
|
|
st.write('# Symptoms to Disease Prediction') |
|
|
|
symptoms = st.multiselect('What are your symptoms?', options=disease_model.all_symptoms) |
|
|
|
X = prepare_symptoms_array(symptoms) |
|
|
|
|
|
if st.button('Predict'): |
|
|
|
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]}') |