Spaces:
Runtime error
Runtime error
Commit
·
77cf1b5
1
Parent(s):
42ca1ef
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,48 +12,46 @@ stroke_dict = {0:"No",
|
|
| 12 |
1: "Yes"}
|
| 13 |
|
| 14 |
model = joblib.load('model.joblib')
|
| 15 |
-
unique_values = joblib.load('unique_values.joblib')
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
unique_race = unique_values["race"]
|
| 24 |
-
unique_country = unique_values["native.country"]
|
| 25 |
|
| 26 |
def main():
|
| 27 |
-
st.title("
|
| 28 |
|
| 29 |
with st.form("questionaire"):
|
|
|
|
| 30 |
age = st.slider("Age" , min_value=10 , max_value=100)
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
native_country = st.selectbox("Native country" , options=unique_country)
|
| 40 |
|
| 41 |
# clicked==True only when the button is clicked
|
| 42 |
clicked = st.form_submit_button("Predict income")
|
| 43 |
if clicked:
|
| 44 |
-
result=model.predict(pd.DataFrame({"
|
| 45 |
-
"
|
| 46 |
-
"
|
| 47 |
-
"
|
| 48 |
-
"
|
| 49 |
-
"
|
| 50 |
-
"
|
| 51 |
-
"
|
| 52 |
-
"
|
| 53 |
-
"
|
| 54 |
# Show prediction
|
| 55 |
-
result = '
|
| 56 |
-
st.success("Your
|
| 57 |
|
| 58 |
# Run main()
|
| 59 |
if __name__ == "__main__" :
|
|
|
|
| 12 |
1: "Yes"}
|
| 13 |
|
| 14 |
model = joblib.load('model.joblib')
|
| 15 |
+
unique_values = joblib.load('unique_values.joblib')
|
| 16 |
+
unique_gender = unique_values["gender"]
|
| 17 |
+
unique_hypertension = unique_values["hypertension"]
|
| 18 |
+
unique_heart_disease = unique_values["heart_disease"]
|
| 19 |
+
unique_ever_married = unique_values["ever_married"]
|
| 20 |
+
unique_work_type = unique_values["work_type"]
|
| 21 |
+
unique_Residence_type = unique_values["Residence_type"]
|
| 22 |
+
unique_smoking_status = unique_values["smoking_status"]
|
|
|
|
|
|
|
| 23 |
|
| 24 |
def main():
|
| 25 |
+
st.title("Stroke Prediction")
|
| 26 |
|
| 27 |
with st.form("questionaire"):
|
| 28 |
+
gender = st.selectbox("Gender" , options=unique_gender)
|
| 29 |
age = st.slider("Age" , min_value=10 , max_value=100)
|
| 30 |
+
hypertension= st.selectbox("Do you have Hypertension ? " , options=unique_hypertension)
|
| 31 |
+
heart_disease= st.selectbox("Do you have any Heart Desease ? " , options=unique_heart_disease)
|
| 32 |
+
ever_married = st.selectbox("Have you ever married ? " , options=unique_ever_married)
|
| 33 |
+
work_type= st.selectbox("What kind of job do you do ? " , options=unique_work_type)
|
| 34 |
+
Residence_type= st.selectbox("Which kind of place do you live in ? " , options=unique_Residence_type)
|
| 35 |
+
smoking_status= st.selectbox("Do you smoke ? " , options=unique_smoking_status )
|
| 36 |
+
bmi = st.number_input(label="What is your BMI" ,step=1.,format="%.2f")
|
| 37 |
+
avg_glucose_level= st.number_input(label="What is your average glucose level" ,step=1.,format="%.2f")
|
|
|
|
| 38 |
|
| 39 |
# clicked==True only when the button is clicked
|
| 40 |
clicked = st.form_submit_button("Predict income")
|
| 41 |
if clicked:
|
| 42 |
+
result=model.predict(pd.DataFrame({"gender": [gender],
|
| 43 |
+
"age": [age],
|
| 44 |
+
"hypertension": [hypertension],
|
| 45 |
+
"heart_disease": [heart_disease],
|
| 46 |
+
"ever_married": [ever_married],
|
| 47 |
+
"work_type": [work_type],
|
| 48 |
+
"Residence_type": [Residence_type],
|
| 49 |
+
"avg_glucose_level":[avg_glucose_level],
|
| 50 |
+
"bmi""[bmi],
|
| 51 |
+
"smoking_status":[smoking_status]}))
|
| 52 |
# Show prediction
|
| 53 |
+
result = 'You may not have a stroke' if result[0] == 1 else 'You may have a stroke'
|
| 54 |
+
st.success("Your prediction "+result)
|
| 55 |
|
| 56 |
# Run main()
|
| 57 |
if __name__ == "__main__" :
|