BlueberryChickenPie commited on
Commit
77cf1b5
·
1 Parent(s): 42ca1ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -32
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
- unique_class = unique_values["workclass"]
18
- unique_education = unique_values["education"]
19
- unique_marital_status = unique_values["marital.status"]
20
- unique_relationship = unique_values["relationship"]
21
- unique_occupation = unique_values["occupation"]
22
- unique_sex = unique_values["sex"]
23
- unique_race = unique_values["race"]
24
- unique_country = unique_values["native.country"]
25
 
26
  def main():
27
- st.title("Adult Income")
28
 
29
  with st.form("questionaire"):
 
30
  age = st.slider("Age" , min_value=10 , max_value=100)
31
- workclass = st.selectbox("Workclass" , options=unique_class)
32
- education = st.selectbox("Education" , options=unique_education)
33
- Marital_Status = st.selectbox("Marital status" , options=unique_marital_status)
34
- occupation = st.selectbox("Occupation" , options=unique_occupation)
35
- relationship = st.selectbox("Relationship" , options=unique_relationship)
36
- race = st.selectbox("Race" , options=unique_race)
37
- sex = st.selectbox("Sex" , options=unique_sex)
38
- hours_per_week = st.slider("Hours per week" , min_value=1 , max_value=100)
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({"age": [age],
45
- "workclass": [workclass],
46
- "education": [EDU_DICT[education]],
47
- "marital.status": [Marital_Status],
48
- "occupation": [occupation],
49
- "relationship": [relationship],
50
- "race": [race],
51
- "sex": [sex],
52
- "hours.per.week": [hours_per_week],
53
- "native.country": [native_country]}))
54
  # Show prediction
55
- result = '>50k' if result[0] == 1 else '<=50k'
56
- st.success("Your predicted income is "+result)
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__" :