Skip to content

Commit 1849786

Browse files
committed
More corrections of notebook
1 parent 5b9e51d commit 1849786

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

examples/risk_control/2-advanced-analysis/plot_risk_control_multi_parameter_binary_classification.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
#############################################################################
9898
# Third define a multiparameter prediciton function
9999
def send_to_human(X, lambda_1, lambda_2):
100-
y_score = clf.predict_proba(X)
100+
y_score = clf.predict_proba(X)[:,1]
101101
return (lambda_1 <= y_score) & (y_score < lambda_2)
102102

103103

@@ -114,6 +114,7 @@ def send_to_human(X, lambda_1, lambda_2):
114114
if lambda_2 > 0.99:
115115
break
116116
to_explore.append((lambda_1, lambda_2))
117+
to_explore = np.array(to_explore)
117118

118119
#############################################################################
119120
# As we want to control the proportion of mail to be verified by a human.
@@ -140,6 +141,7 @@ def send_to_human(X, lambda_1, lambda_2):
140141
risk=prop_positive,
141142
target_level=target_level,
142143
confidence_level=confidence_level,
144+
best_predict_param_choice="precision",
143145
predict_params=to_explore,
144146
)
145147
bcc.calibrate(X_calib, y_calib)
@@ -155,12 +157,12 @@ def send_to_human(X, lambda_1, lambda_2):
155157
for valid_params in bcc.valid_predict_params:
156158
row = valid_params[0] * 10
157159
col = valid_params[1] * 10
158-
matrix[row, col] = 1
160+
matrix[int(row), int(col)] = 1
159161

160162
fig, ax = plt.subplots(figsize=(16, 12))
161163
im = ax.imshow(matrix)
162164
ax.set_xticks(range(10), labels=(np.array(range(10)) / 10))
163-
ax.set_yticks(range(10, labels=(np.array(range(10)) / 10)))
165+
ax.set_yticks(range(10), labels=(np.array(range(10)) / 10))
164166
ax.set_title("Validated parameters")
165167
fig.tight_layout()
166168
plt.show()

0 commit comments

Comments
 (0)