Beladiaamy commited on
Commit
ecd4ae1
·
verified ·
1 Parent(s): e06f270

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -1
app.py CHANGED
@@ -65,11 +65,56 @@ def map_DiffWalk(value):
65
  mapping = {'No': 0, 'Yes': 1}
66
  return mapping[value]
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
 
 
 
 
 
 
 
 
 
69
 
70
  # Create the main function for server
71
  def main_func(HighBP, HighChol, CholCheck, BMI, Smoker, Stroke, HeartDiseaseorAttack, PhysActivity, Fruits, Veggies, HvyAlcoholConsump, AnyHealthcare, NoDocbcCost, GenHlth, MentHlth, PhysHlth, DiffWalk, Sex, Age, Education, Income):
72
- new_row = pd.DataFrame.from_dict({'HighBP': map_HighBP(HighBP), 'HighChol': map_HighChol(HighChol), 'CholCheck': map_CholCheck(CholCheck), 'BMI': BMI, 'Smoker': map_Smoker(Smoker), 'Stroke': map_Stroke(Stroke), 'HeartDiseaseorAttack': map_HeartDiseaseorAttack(HeartDiseaseorAttack), 'PhysActivity': map_PhysActivity(PhysActivity), 'Fruits': map_Fruits(Fruits), 'Veggies': map_Veggies(Veggies), 'HvyAlcoholConsump': map_HvyAlcoholConsump(HvyAlcoholConsump), 'AnyHealthcare': map_AnyHealthcare(AnyHealthcare), 'NoDocbcCost': map_NoDocbcCost(NoDocbcCost), 'GenHlth': GenHlth, 'MentHlth': MentHlth, 'PhysHlth': PhysHlth, 'DiffWalk': map_DiffWalk(DiffWalk), 'Sex': Sex, 'Age': Age, 'Education': Education, 'Income': Income}, orient='index').transpose()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
 
75
  prob = loaded_model.predict_proba(new_row)
 
65
  mapping = {'No': 0, 'Yes': 1}
66
  return mapping[value]
67
 
68
+ def map_gender(value):
69
+ mapping = {'Female': 0, 'Male': 1}
70
+ return mapping[value]
71
+
72
+ def map_education(value):
73
+ mapping = {
74
+ "Never attended school": 0,
75
+ "Grades 1-8": 1,
76
+ "Grades 9-11": 2,
77
+ "Grade 12 or GED": 3,
78
+ "College 1-3 years": 4,
79
+ "College 4+ years": 5
80
+ }
81
+ return mapping[value]
82
 
83
+ def map_income(value):
84
+ mapping = {
85
+ "< $10,000": 0,
86
+ "$10,000 - $24,999": 1,
87
+ "$25,000 - $49,999": 2,
88
+ "$50,000 - $74,999": 3,
89
+ "$75,000 or more": 4
90
+ }
91
+ return mapping[value]
92
 
93
  # Create the main function for server
94
  def main_func(HighBP, HighChol, CholCheck, BMI, Smoker, Stroke, HeartDiseaseorAttack, PhysActivity, Fruits, Veggies, HvyAlcoholConsump, AnyHealthcare, NoDocbcCost, GenHlth, MentHlth, PhysHlth, DiffWalk, Sex, Age, Education, Income):
95
+ new_row = pd.DataFrame.from_dict({
96
+ 'HighBP': map_yes_no(HighBP),
97
+ 'HighChol': map_yes_no(HighChol),
98
+ 'CholCheck': map_yes_no(CholCheck),
99
+ 'BMI': BMI,
100
+ 'Smoker': map_yes_no(Smoker),
101
+ 'Stroke': map_yes_no(Stroke),
102
+ 'HeartDiseaseorAttack': map_yes_no(HeartDiseaseorAttack),
103
+ 'PhysActivity': map_yes_no(PhysActivity),
104
+ 'Fruits': map_yes_no(Fruits),
105
+ 'Veggies': map_yes_no(Veggies),
106
+ 'HvyAlcoholConsump': map_yes_no(HvyAlcoholConsump),
107
+ 'AnyHealthcare': map_yes_no(AnyHealthcare),
108
+ 'NoDocbcCost': map_yes_no(NoDocbcCost),
109
+ 'GenHlth': GenHlth,
110
+ 'MentHlth': MentHlth,
111
+ 'PhysHlth': PhysHlth,
112
+ 'DiffWalk': map_yes_no(DiffWalk),
113
+ 'Sex': map_gender(Sex),
114
+ 'Age': Age,
115
+ 'Education': map_education(Education),
116
+ 'Income': map_income(Income)
117
+ }, orient='index').transpose()
118
 
119
 
120
  prob = loaded_model.predict_proba(new_row)