Spaces:
Runtime error
Runtime error
Update app_function.py
Browse files- app_function.py +0 -48
app_function.py
CHANGED
@@ -91,54 +91,6 @@ def loading_data():
|
|
91 |
return results
|
92 |
|
93 |
|
94 |
-
|
95 |
-
# Function use to get the user input data
|
96 |
-
def user_input(HighBP,HighChol, CholCheck, BMI, Smoker,Stroke,HeartDiseaseorAttack,
|
97 |
-
PhysActivity, Fruits, Veggies,HvyAlcoholConsump,AnyHealthcare, NoDocbcCost, GenHlth,
|
98 |
-
MentHlth, PhysHlth, DiffWalk,
|
99 |
-
Sex, Age, Education,Income):
|
100 |
-
|
101 |
-
user_data = {'HighBP':HighBP, 'HighChol':HighChol, 'CholCheck':CholCheck, 'BMI':BMI, 'Smoker':Smoker,
|
102 |
-
'Stroke':Stroke, 'HeartDiseaseorAttack':HeartDiseaseorAttack, 'PhysActivity':PhysActivity, 'Fruits':Fruits, 'Veggies':Veggies,
|
103 |
-
'HvyAlcoholConsump':HvyAlcoholConsump, 'AnyHealthcare':AnyHealthcare, 'NoDocbcCost':NoDocbcCost, 'GenHlth':GenHlth,
|
104 |
-
'MentHlth':MentHlth, 'PhysHlth':PhysHlth, 'DiffWalk':DiffWalk, 'Sex':Sex, 'Age':Age, 'Education':Education,
|
105 |
-
'Income':Income}
|
106 |
-
|
107 |
-
user_df = pd.DataFrame(user_data,index=[0])
|
108 |
-
|
109 |
-
## Load Model from pickle file
|
110 |
-
with open("Model_package.pkl","rb") as f:
|
111 |
-
Model_package = pickle.load(f)
|
112 |
-
model = Model_package['my_classif']
|
113 |
-
|
114 |
-
#LOADING THE DATA
|
115 |
-
results = loading_data()
|
116 |
-
num_col_trans = results["num_col_trans"]
|
117 |
-
cat_col_trans = results["cat_col_trans"]
|
118 |
-
|
119 |
-
|
120 |
-
# Data preparation before fitting to the model
|
121 |
-
user_df["Age2"] = user_df["Age"]**2
|
122 |
-
user_df_std = num_col_trans.transform(user_df)
|
123 |
-
user_df_std = pd.DataFrame(user_df_std ,columns=list(user_df.columns) )
|
124 |
-
user_df_encoded = cat_col_trans.transform(user_df_std)
|
125 |
-
user_encoded = np.array(user_df_encoded).reshape((1,-1))
|
126 |
-
|
127 |
-
|
128 |
-
#PREDICTION
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
target_names = ['No diabetes', 'Prediabetes', 'Diabetes']
|
133 |
-
|
134 |
-
pred_proba = model.predict_proba(user_encoded)[0]
|
135 |
-
|
136 |
-
|
137 |
-
return {classe : pred_proba[i] for i, classe in enumerate(target_names)}
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
# Get PDF File for user
|
143 |
def get_data_inputPDF(PDF_file):
|
144 |
|
|
|
91 |
return results
|
92 |
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
# Get PDF File for user
|
95 |
def get_data_inputPDF(PDF_file):
|
96 |
|