|
|
|
"""app.ipynb |
|
|
|
Automatically generated by Colaboratory. |
|
|
|
Original file is located at |
|
https://colab.research.google.com/drive/1NiGtTsWgQO-_sqya-2Qexup3M8BcmfYI |
|
""" |
|
|
|
import joblib |
|
import pandas as pd |
|
import streamlit as st |
|
|
|
AgeCategory_new = {'18-24':1, |
|
'25-29':2, |
|
'30-34':3, |
|
'35-39':4, |
|
'40-44':5, |
|
'45-49':6, |
|
'50-54':7, |
|
'55-59':8, |
|
'60-64':9, |
|
'65-69':10, |
|
'70-74':11, |
|
'75-79':12, |
|
'80 or older':13} |
|
|
|
model = joblib.load('model.joblib') |
|
unique_values = joblib.load('unique_values.joblib') |
|
|
|
unique_Smoking = unique_values["Smoking"] |
|
unique_AlcoholDrinking = unique_values["AlcoholDrinking"] |
|
unique_Stroke = unique_values["Stroke"] |
|
unique_DiffWalking = unique_values["DiffWalking"] |
|
unique_Sex = unique_values["Sex"] |
|
unique_Race = unique_values["Race"] |
|
unique_Diabetic = unique_values["Diabetic"] |
|
unique_PhysicalActivity = unique_values["PhysicalActivity"] |
|
unique_GenHealth = unique_values["GenHealth"] |
|
unique_Asthma = unique_values["Asthma"] |
|
unique_KidneyDisease = unique_values["KidneyDisease"] |
|
unique_SkinCancer = unique_values["SkinCancer"] |
|
unique_AgeCategory = unique_values["AgeCategory"] |
|
|
|
def main(): |
|
st.title("Personal Key Indicators of Heart Disease") |
|
|
|
with st.form("questionaire"): |
|
BMI = st.slider("BMI", min_value=10, max_value=100) |
|
Smoking = st.selectbox("Smoking", unique_Smoking) |
|
AlcoholDrinking = st.selectbox("AlcoholDrinking", unique_AlcoholDrinking) |
|
Stroke = st.selectbox("Stroke", unique_Stroke) |
|
PhysicalHealth = st.slider("PhysicalHealth", min_value=0, max_value=50) |
|
MentalHealth = st.slider("MentalHealth", min_value=0, max_value=50) |
|
DiffWalking = st.selectbox("DiffWalking", unique_DiffWalking) |
|
Sex = st.selectbox("Sex", unique_Sex) |
|
AgeCategory = st.selectbox("AgeCategory_new", unique_AgeCategory) |
|
Race = st.selectbox("Race", unique_Race) |
|
Diabetic = st.selectbox("Diabetic", unique_Diabetic) |
|
PhysicalActivity = st.selectbox("PhysicalActivity", unique_PhysicalActivity) |
|
GenHealth = st.selectbox("GenHealth", unique_GenHealth) |
|
SleepTime = st.slider("SleepTime", min_value=0, max_value=24) |
|
Asthma = st.selectbox("Asthma", unique_Asthma) |
|
KidneyDisease = st.selectbox("KidneyDisease", unique_KidneyDisease) |
|
SkinCancer = st.selectbox("SkinCancer", unique_SkinCancer) |
|
|
|
clicked = st.form_submit_button("Predict HeartDisease") |
|
if clicked: |
|
result=model.predict(pd.DataFrame({"BMI": [BMI], |
|
"Smoking": [Smoking], |
|
"AlcoholDrinking": [AlcoholDrinking], |
|
"Stroke": [Stroke], |
|
"PhysicalHealth": [PhysicalHealth], |
|
"MentalHealth": [MentalHealth], |
|
"DiffWalking": [DiffWalking], |
|
"Sex": [Sex], |
|
"AgeCategory": [AgeCategory_new[AgeCategory]], |
|
"Race": [Race], |
|
"Diabetic": [Diabetic], |
|
"PhysicalActivity": [PhysicalActivity], |
|
"GenHealth": [GenHealth], |
|
"SleepTime": [SleepTime], |
|
"Asthma": [Asthma], |
|
"KidneyDisease": [KidneyDisease], |
|
"SkinCancer": [SkinCancer]})) |
|
result = 'You are at risk of developing heart disease.' if result[0] == 1 else 'You are not at risk of heart disease.' |
|
st.success('The predicted HeartDisease is {}'.format(result)) |
|
|
|
if __name__=='__main__': |
|
main() |