Spaces:
Runtime error
Runtime error
sohamagarwal
commited on
Commit
•
dd42793
1
Parent(s):
3d31f1b
Upload 3 files
Browse files- clf.sav +0 -0
- hattack_predictor.py +125 -0
- requirements.txt +59 -0
clf.sav
ADDED
Binary file (566 kB). View file
|
|
hattack_predictor.py
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""
|
3 |
+
Created on Mon Feb 27 16:17:01 2023
|
4 |
+
|
5 |
+
@author: soham
|
6 |
+
"""
|
7 |
+
|
8 |
+
import streamlit as st
|
9 |
+
import numpy as np
|
10 |
+
import pandas as pd
|
11 |
+
import joblib
|
12 |
+
import sklearn
|
13 |
+
|
14 |
+
def predict(data):
|
15 |
+
clf = joblib.load("clf.sav")
|
16 |
+
data=np.array(data).reshape(1,-1)
|
17 |
+
return clf.predict(data)
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
st.title("Mortality predictor")
|
22 |
+
|
23 |
+
st.header("Using heart attack data to predict the possibility of you dying in the said follow up period")
|
24 |
+
|
25 |
+
st.subheader("Kindly enter your details so that we can give you your predictions")
|
26 |
+
|
27 |
+
first_name,last_name = st.columns(2)
|
28 |
+
|
29 |
+
f_name=first_name.text_input("First Name")
|
30 |
+
l_name=last_name.text_input("Last Name")
|
31 |
+
|
32 |
+
button=st.button("Start")
|
33 |
+
|
34 |
+
if button:
|
35 |
+
st.write(f"Welcome {f_name}")
|
36 |
+
|
37 |
+
#####################################
|
38 |
+
|
39 |
+
# now we let the user pass in parameters
|
40 |
+
|
41 |
+
# Age, Anaemia, Creatnine_phosphokinase,diabetes,
|
42 |
+
# ejection_fraction,high_blood_pressure,platelets,
|
43 |
+
# Serum_creatinine, serum_sodium, sex, smoking
|
44 |
+
# time, Death_event (target)
|
45 |
+
|
46 |
+
#For anaemia,diabetes,high_blood_pressure,sex,smoking we need to use a dict
|
47 |
+
|
48 |
+
yes_no_bool = {"Yes":1,"No":0}
|
49 |
+
male_female_bool = {"Male":1,"Female":0}
|
50 |
+
|
51 |
+
st.write("-------------------------------------------")
|
52 |
+
|
53 |
+
age,anaemia,creatinine_phosphokinase = st.columns(3)
|
54 |
+
|
55 |
+
age = age.number_input("Enter your age",min_value=10.00,max_value=100.00) # Maybe add some limits here
|
56 |
+
anaemia = anaemia.radio("Do you have anaemia",["Yes","No"])
|
57 |
+
anaemia = yes_no_bool[anaemia]
|
58 |
+
|
59 |
+
creatinine_phosphokinase= creatinine_phosphokinase.number_input("CPK enzyme levels (mcg/L)",step=1)
|
60 |
+
|
61 |
+
|
62 |
+
st.write("---------------------------------------------")
|
63 |
+
|
64 |
+
diabetes,ejection_fraction,high_blood_pressure = st.columns(3)
|
65 |
+
|
66 |
+
diabetes = diabetes.radio("Do you have diabetes",["Yes","No"])
|
67 |
+
diabetes = yes_no_bool[diabetes]
|
68 |
+
|
69 |
+
ejection_fraction = ejection_fraction.number_input("Percentage of blood leaving",step=1,min_value=0,max_value=100)
|
70 |
+
high_blood_pressure = high_blood_pressure.radio("Do you have Hypertension",["Yes","No"])
|
71 |
+
high_blood_pressure = yes_no_bool[high_blood_pressure]
|
72 |
+
|
73 |
+
|
74 |
+
st.write("---------------------------------------------")
|
75 |
+
|
76 |
+
platelets,serum_creatinine,serum_sodium = st.columns(3)
|
77 |
+
|
78 |
+
platelets = platelets.number_input("Platelets in the blood")
|
79 |
+
serum_creatinine= serum_creatinine.number_input("Level of creatinine (mg/dL)")
|
80 |
+
serum_sodium=serum_sodium.number_input("Level of sodium in the blood (mEq/L)",step=1)
|
81 |
+
|
82 |
+
|
83 |
+
st.write("---------------------------------------------")
|
84 |
+
|
85 |
+
sex,smoking,time = st.columns(3)
|
86 |
+
|
87 |
+
sex = sex.radio("Sex",["Male","Female"])
|
88 |
+
sex = male_female_bool[sex]
|
89 |
+
|
90 |
+
smoking = smoking.radio("Do you smoke?",["Yes","No"])
|
91 |
+
smoking = yes_no_bool[smoking]
|
92 |
+
|
93 |
+
time=time.number_input("Follow up period",step=1)
|
94 |
+
|
95 |
+
st.write("---------------------------------------------")
|
96 |
+
|
97 |
+
|
98 |
+
data_instance=[age,anaemia,creatinine_phosphokinase,diabetes,
|
99 |
+
ejection_fraction,high_blood_pressure,platelets,
|
100 |
+
serum_creatinine,serum_sodium,sex,smoking,time]
|
101 |
+
|
102 |
+
|
103 |
+
st.write("#### Predict the chances of a death event")
|
104 |
+
|
105 |
+
prediction_converter = {0:"Less probability of death",1:"More probability of death"}
|
106 |
+
|
107 |
+
if st.button("Predict"):
|
108 |
+
prediction=predict(data_instance)
|
109 |
+
prediction=prediction_converter[prediction[0]]
|
110 |
+
|
111 |
+
st.write(prediction)
|
112 |
+
|
113 |
+
|
114 |
+
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
|
120 |
+
|
121 |
+
|
122 |
+
|
123 |
+
|
124 |
+
|
125 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
altair==4.2.2
|
2 |
+
attrs==22.2.0
|
3 |
+
blinker==1.5
|
4 |
+
cachetools==5.3.0
|
5 |
+
certifi==2022.12.7
|
6 |
+
charset-normalizer==3.0.1
|
7 |
+
click==8.1.3
|
8 |
+
colorama==0.4.6
|
9 |
+
contourpy==1.0.7
|
10 |
+
cycler==0.11.0
|
11 |
+
decorator==5.1.1
|
12 |
+
entrypoints==0.4
|
13 |
+
fonttools==4.38.0
|
14 |
+
gitdb==4.0.10
|
15 |
+
GitPython==3.1.31
|
16 |
+
idna==3.4
|
17 |
+
importlib-metadata==6.0.0
|
18 |
+
Jinja2==3.1.2
|
19 |
+
joblib==1.2.0
|
20 |
+
jsonschema==4.17.3
|
21 |
+
kiwisolver==1.4.4
|
22 |
+
markdown-it-py==2.2.0
|
23 |
+
MarkupSafe==2.1.2
|
24 |
+
matplotlib==3.7.0
|
25 |
+
mdurl==0.1.2
|
26 |
+
numpy==1.24.2
|
27 |
+
packaging==23.0
|
28 |
+
pandas==1.5.3
|
29 |
+
Pillow==9.4.0
|
30 |
+
protobuf==3.20.3
|
31 |
+
pyarrow==11.0.0
|
32 |
+
pydeck==0.8.0
|
33 |
+
Pygments==2.14.0
|
34 |
+
Pympler==1.0.1
|
35 |
+
pyparsing==3.0.9
|
36 |
+
pyrsistent==0.19.3
|
37 |
+
python-dateutil==2.8.2
|
38 |
+
pytz==2022.7.1
|
39 |
+
pytz-deprecation-shim==0.1.0.post0
|
40 |
+
requests==2.28.2
|
41 |
+
rich==13.3.1
|
42 |
+
scikit-learn==1.2.1
|
43 |
+
scipy==1.10.1
|
44 |
+
semver==2.13.0
|
45 |
+
six==1.16.0
|
46 |
+
sklearn==0.0.post1
|
47 |
+
smmap==5.0.0
|
48 |
+
streamlit==1.19.0
|
49 |
+
threadpoolctl==3.1.0
|
50 |
+
toml==0.10.2
|
51 |
+
toolz==0.12.0
|
52 |
+
tornado==6.2
|
53 |
+
typing_extensions==4.5.0
|
54 |
+
tzdata==2022.7
|
55 |
+
tzlocal==4.2
|
56 |
+
urllib3==1.26.14
|
57 |
+
validators==0.20.0
|
58 |
+
watchdog==2.3.0
|
59 |
+
zipp==3.15.0
|