Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,65 +1,46 @@
|
|
| 1 |
import joblib
|
| 2 |
import pandas as pd
|
|
|
|
| 3 |
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
'11th': 7,
|
| 12 |
-
'12th': 8,
|
| 13 |
-
'HS-grad': 9,
|
| 14 |
-
'Some-college': 10,
|
| 15 |
-
'Assoc-voc': 11,
|
| 16 |
-
'Assoc-acdm': 12,
|
| 17 |
-
'Bachelors': 13,
|
| 18 |
-
'Masters': 14,
|
| 19 |
-
'Prof-school': 15,
|
| 20 |
-
'Doctorate': 16
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
model = #
|
| 24 |
-
unique_values = #
|
| 25 |
-
|
| 26 |
-
unique_class = unique_values["workclass"]
|
| 27 |
-
unique_education = unique_values["education"]
|
| 28 |
-
unique_marital_status = unique_values["marital.status"]
|
| 29 |
-
unique_relationship = unique_values["relationship"]
|
| 30 |
-
unique_occupation = unique_values["occupation"]
|
| 31 |
-
unique_sex = unique_values["sex"]
|
| 32 |
-
unique_race = unique_values["race"]
|
| 33 |
-
unique_country = unique_values["native.country"]
|
| 34 |
|
| 35 |
def main():
|
| 36 |
-
st.title("
|
| 37 |
-
|
| 38 |
with st.form("questionaire"):
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
native_country = # user's input
|
| 49 |
|
| 50 |
# clicked==True only when the button is clicked
|
| 51 |
-
clicked = st.form_submit_button("Predict
|
| 52 |
if clicked:
|
| 53 |
-
result=model.predict(pd.DataFrame({"
|
| 54 |
-
"
|
| 55 |
-
"
|
| 56 |
-
"
|
| 57 |
-
"
|
| 58 |
-
"
|
| 59 |
-
"
|
| 60 |
-
"
|
| 61 |
-
"
|
| 62 |
-
"native.country": [native_country]}))
|
| 63 |
# Show prediction
|
| 64 |
-
|
|
|
|
| 65 |
# Run main()
|
|
|
|
|
|
|
|
|
| 1 |
import joblib
|
| 2 |
import pandas as pd
|
| 3 |
+
import streamlit as st
|
| 4 |
|
| 5 |
+
model = joblib.load("model.joblib")#
|
| 6 |
+
unique_values = joblib.load("unique_values.joblib")#
|
| 7 |
|
| 8 |
+
unique_gender = unique_values["gender"]
|
| 9 |
+
unique_hypertension = unique_values["hypertension"]
|
| 10 |
+
unique_heart_disease = unique_values["heart_disease"]
|
| 11 |
+
unique_work_type = unique_values["work_type"]
|
| 12 |
+
unique_residence_type = unique_values["Residence_type"]
|
| 13 |
+
unique_smoking_status = unique_values["smoking_status"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def main():
|
| 16 |
+
st.title("Stroke Prediction")
|
| 17 |
+
|
| 18 |
with st.form("questionaire"):
|
| 19 |
+
Gender = st.selectbox("Gender", options=unique_gender)
|
| 20 |
+
Age = st.slider("Age", min_value=10, max_value=100)
|
| 21 |
+
Hypertension = st.selectbox("Hypertension", options=unique_hypertension)
|
| 22 |
+
Heart_Disease = st.selectbox("Heart_Disease", options=unique_heart_disease)
|
| 23 |
+
Work_type = st.selectbox("Work", options=unique_work_type)
|
| 24 |
+
Residence = st.selectbox("Residence", options=unique_residence_type)
|
| 25 |
+
Glucose_Level = st.number_input("Glucose_Level")
|
| 26 |
+
BMI = st.number_input("BMI")
|
| 27 |
+
Smoking = st.selectbox("Smoking", options=unique_smoking_status)
|
|
|
|
| 28 |
|
| 29 |
# clicked==True only when the button is clicked
|
| 30 |
+
clicked = st.form_submit_button("Predict Stroke")
|
| 31 |
if clicked:
|
| 32 |
+
result=model.predict(pd.DataFrame({"Gender": [Gender],
|
| 33 |
+
"Age": [Age],
|
| 34 |
+
"Hypertension": [Hypertension],
|
| 35 |
+
"Heart_Disease": [Heart_Disease],
|
| 36 |
+
"Work_type": [Work_type],
|
| 37 |
+
"Residence": [Residence],
|
| 38 |
+
"Avg_Glucose_Level": [Glucose_Level],
|
| 39 |
+
"BMI": [BMI],
|
| 40 |
+
"Smoking": [Smoking]}))
|
|
|
|
| 41 |
# Show prediction
|
| 42 |
+
result = 'Yes' if result[0] == 1 else 'No'
|
| 43 |
+
st.success("Your predicted Stroke is ",result)
|
| 44 |
# Run main()
|
| 45 |
+
if __name__ == "__main__":
|
| 46 |
+
main()
|