Upload 4 files
Browse files- app.py +90 -0
- model.joblib +3 -0
- requirements.txt +5 -0
- unique_values.joblib +3 -0
app.py
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""app.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1NiGtTsWgQO-_sqya-2Qexup3M8BcmfYI
|
8 |
+
"""
|
9 |
+
|
10 |
+
import joblib
|
11 |
+
import pandas as pd
|
12 |
+
import streamlit as st
|
13 |
+
|
14 |
+
AgeCategory_new = {'18-24':1,
|
15 |
+
'25-29':2,
|
16 |
+
'30-34':3,
|
17 |
+
'35-39':4,
|
18 |
+
'40-44':5,
|
19 |
+
'45-49':6,
|
20 |
+
'50-54':7,
|
21 |
+
'55-59':8,
|
22 |
+
'60-64':9,
|
23 |
+
'65-69':10,
|
24 |
+
'70-74':11,
|
25 |
+
'75-79':12,
|
26 |
+
'80 or older':13}
|
27 |
+
|
28 |
+
model = joblib.load('model.joblib')
|
29 |
+
unique_values = joblib.load('unique_values.joblib')
|
30 |
+
|
31 |
+
unique_Smoking = unique_values["Smoking"]
|
32 |
+
unique_AlcoholDrinking = unique_values["AlcoholDrinking"]
|
33 |
+
unique_Stroke = unique_values["Stroke"]
|
34 |
+
unique_DiffWalking = unique_values["DiffWalking"]
|
35 |
+
unique_Sex = unique_values["Sex"]
|
36 |
+
unique_race = unique_values["race"]
|
37 |
+
unique_Diabetic = unique_values["Diabetic"]
|
38 |
+
unique_PhysicalActivity = unique_values["PhysicalActivity"]
|
39 |
+
unique_GenHealth = unique_values["GenHealth"]
|
40 |
+
unique_Asthma = unique_values["Asthma"]
|
41 |
+
unique_KidneyDisease = unique_values["KidneyDisease"]
|
42 |
+
unique_SkinCancer = unique_values["SkinCancer"]
|
43 |
+
unique_AgeCategory = unique_values["AgeCategory"]
|
44 |
+
|
45 |
+
def main():
|
46 |
+
st.title("Personal Key Indicators of Heart Disease")
|
47 |
+
|
48 |
+
with st.form("questionaire"):
|
49 |
+
BMI = st.slider("BMI", min_value=10, max_value=100)
|
50 |
+
Smoking = st.selectbox("Smoking", unique_Smoking)
|
51 |
+
AlcoholDrinking = ("AlcoholDrinking", unique_AlcoholDrinking)
|
52 |
+
Stroke = ("Stroke", unique_Stroke)
|
53 |
+
PhysicalHealth = st.slider("PhysicalHealth", min_value=0, max_value=50)
|
54 |
+
MentalHealth = st.slider("MentalHealth", min_value=0, max_value=50)
|
55 |
+
DiffWalking = ("DiffWalking", unique_DiffWalking)
|
56 |
+
Sex = ("Sex", unique_Sex)
|
57 |
+
AgeCategory = ("AgeCategory_new", unique_AgeCategory)
|
58 |
+
Race = ("Race", unique_Race)
|
59 |
+
Diabetic = ("Diabetic", unique_Diabetic)
|
60 |
+
PhysicalActivity = ("PhysicalActivity", unique_PhysicalActivity)
|
61 |
+
GenHealth = ("GenHealth", unique_GenHealth)
|
62 |
+
SleepTime = st.slider("SleepTime", min_value=0, max_value=24)
|
63 |
+
Asthma = ("Asthma", unique_Asthma)
|
64 |
+
KidneyDisease = ("KidneyDisease", unique_KidneyDisease)
|
65 |
+
SkinCancer = ("SkinCancer", unique_SkinCancer)
|
66 |
+
|
67 |
+
clicked = st.form_submit_button("Predict HeartDisease")
|
68 |
+
if clicked:
|
69 |
+
result=model.predict(pd.DataFrame({"BMI": [BMI],
|
70 |
+
"Smoking": [Smoking],
|
71 |
+
"AlcoholDrinking": [AlcoholDrinking],
|
72 |
+
"Stroke": [Stroke],
|
73 |
+
"PhysicalHealth": [PhysicalHealth],
|
74 |
+
"MentalHealth": [MentalHealth],
|
75 |
+
"DiffWalking": [DiffWalking],
|
76 |
+
"sex": [sex],
|
77 |
+
"AgeCategory_new": [AgeCategory_new[AgeCategory]],
|
78 |
+
"race": [race],
|
79 |
+
"Diabetic": [Diabetic],
|
80 |
+
"PhysicalActivity": [PhysicalActivity],
|
81 |
+
"GenHealth": [GenHealth],
|
82 |
+
"SleepTime": [SleepTime],
|
83 |
+
"Asthma": [Asthma],
|
84 |
+
"KidneyDisease": [KidneyDisease],
|
85 |
+
"SkinCancer": [SkinCancer]}))
|
86 |
+
result = 'Yes' if result[0] == 1 else 'No'
|
87 |
+
st.success('The predicted HeartDisease is {}'.format(result))
|
88 |
+
|
89 |
+
if __name__=='__main__':
|
90 |
+
main()
|
model.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3c33bab3a333ca2956756983f530d1ec727da8d6f285f9b1f8ffb92939dd559e
|
3 |
+
size 400322
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
joblib
|
2 |
+
pandas
|
3 |
+
scikit-learn==1.2.2
|
4 |
+
xgboost==1.7.6
|
5 |
+
altair<5
|
unique_values.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f88a8401450d235f5b3db981bed97ba6fbebedb3f88bb4d700cb1b49332e5a3c
|
3 |
+
size 3731
|