mertkarabacak
commited on
Commit
•
aa3c555
1
Parent(s):
2d99f73
Upload app.py
Browse files
app.py
CHANGED
@@ -124,7 +124,7 @@ x1_rf = x1_rf.astype(d1)
|
|
124 |
|
125 |
#Assign hyperparameters.
|
126 |
y1_xgb_params = {'objective': 'binary:logistic', 'booster': 'gbtree', 'lambda': 3.540855010579091e-08, 'alpha': 4.005546508605542e-08, 'max_depth': 5, 'eta': 5.190362998186933e-08, 'gamma': 1.1458984717217304e-05, 'grow_policy': 'depthwise'}
|
127 |
-
y1_lgb_params = {'objective': 'binary', 'boosting_type': 'gbdt', 'lambda_l1': 0.5873889067286373, 'lambda_l2': 0.0043364331356120405, 'num_leaves': 221, 'feature_fraction': 0.8036023624154648, 'bagging_fraction': 0.43028542431491096, 'bagging_freq': 5, 'min_child_samples': 7}
|
128 |
y1_cb_params = {'objective': 'Logloss', 'colsample_bylevel': 0.02893626365611705, 'depth': 9, 'boosting_type': 'Plain', 'bootstrap_type': 'Bayesian', 'bagging_temperature': 0.8396785798333539}
|
129 |
y1_rf_params = {'criterion': 'entropy', 'max_features': None, 'max_depth': 71, 'n_estimators': 900, 'min_samples_leaf': 4, 'min_samples_split': 5}
|
130 |
|
@@ -195,31 +195,33 @@ def y1_interpret_xgb(*args):
|
|
195 |
shap_values = y1_explainer_xgb.shap_values(xgb.DMatrix(df, enable_categorical=True))
|
196 |
shap.bar_plot(shap_values[0], max_display = 10, show = False, feature_names = f_names)
|
197 |
fig_y1 = plt.gcf()
|
198 |
-
fig_y1.set_figheight(6)
|
199 |
-
fig_y1.set_figwidth(8)
|
200 |
ax_y1 = plt.gca()
|
|
|
|
|
201 |
plt.tight_layout()
|
|
|
|
|
202 |
plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8)
|
203 |
plt.tick_params(axis="y",direction="out", labelsize = 12)
|
204 |
plt.tick_params(axis="x",direction="out", labelsize = 12)
|
205 |
-
wrap_labels(ax_y1, 30)
|
206 |
-
ax_y1.figure
|
207 |
return fig_y1
|
208 |
|
209 |
def y1_interpret_lgb(*args):
|
210 |
df = pd.DataFrame([args], columns=x1_lgb.columns)
|
211 |
df = df.astype({col: "category" for col in categorical_columns1})
|
212 |
shap_values = y1_explainer_lgb.shap_values(df)
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
plt.
|
219 |
-
|
220 |
-
|
221 |
-
plt.
|
222 |
-
|
|
|
|
|
223 |
|
224 |
def y1_interpret_cb(*args):
|
225 |
df = pd.DataFrame([args], columns=x1.columns)
|
|
|
124 |
|
125 |
#Assign hyperparameters.
|
126 |
y1_xgb_params = {'objective': 'binary:logistic', 'booster': 'gbtree', 'lambda': 3.540855010579091e-08, 'alpha': 4.005546508605542e-08, 'max_depth': 5, 'eta': 5.190362998186933e-08, 'gamma': 1.1458984717217304e-05, 'grow_policy': 'depthwise'}
|
127 |
+
y1_lgb_params = {'objective': 'binary', 'boosting_type': 'gbdt', 'lambda_l1': 0.5873889067286373, 'lambda_l2': 0.0043364331356120405, 'num_leaves': 221, 'feature_fraction': 0.8036023624154648, 'bagging_fraction': 0.43028542431491096, 'bagging_freq': 5, 'min_child_samples': 7, 'verbosity': -1}
|
128 |
y1_cb_params = {'objective': 'Logloss', 'colsample_bylevel': 0.02893626365611705, 'depth': 9, 'boosting_type': 'Plain', 'bootstrap_type': 'Bayesian', 'bagging_temperature': 0.8396785798333539}
|
129 |
y1_rf_params = {'criterion': 'entropy', 'max_features': None, 'max_depth': 71, 'n_estimators': 900, 'min_samples_leaf': 4, 'min_samples_split': 5}
|
130 |
|
|
|
195 |
shap_values = y1_explainer_xgb.shap_values(xgb.DMatrix(df, enable_categorical=True))
|
196 |
shap.bar_plot(shap_values[0], max_display = 10, show = False, feature_names = f_names)
|
197 |
fig_y1 = plt.gcf()
|
|
|
|
|
198 |
ax_y1 = plt.gca()
|
199 |
+
wrap_labels(ax_y1, 30)
|
200 |
+
ax_y1.figure
|
201 |
plt.tight_layout()
|
202 |
+
fig_y1.set_figheight(6)
|
203 |
+
fig_y1.set_figwidth(8)
|
204 |
plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8)
|
205 |
plt.tick_params(axis="y",direction="out", labelsize = 12)
|
206 |
plt.tick_params(axis="x",direction="out", labelsize = 12)
|
|
|
|
|
207 |
return fig_y1
|
208 |
|
209 |
def y1_interpret_lgb(*args):
|
210 |
df = pd.DataFrame([args], columns=x1_lgb.columns)
|
211 |
df = df.astype({col: "category" for col in categorical_columns1})
|
212 |
shap_values = y1_explainer_lgb.shap_values(df)
|
213 |
+
shap.bar_plot(shap_values[0][0], max_display = 10, show = False, feature_names = f_names)
|
214 |
+
fig_y1 = plt.gcf()
|
215 |
+
ax_y1 = plt.gca()
|
216 |
+
wrap_labels(ax_y1, 30)
|
217 |
+
ax_y1.figure
|
218 |
+
plt.tight_layout()
|
219 |
+
fig_y1.set_figheight(6)
|
220 |
+
fig_y1.set_figwidth(8)
|
221 |
+
plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8)
|
222 |
+
plt.tick_params(axis="y",direction="out", labelsize = 12)
|
223 |
+
plt.tick_params(axis="x",direction="out", labelsize = 12)
|
224 |
+
return fig_y1
|
225 |
|
226 |
def y1_interpret_cb(*args):
|
227 |
df = pd.DataFrame([args], columns=x1.columns)
|