9797#############################################################################
9898# Third define a multiparameter prediciton function
9999def 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)
145147bcc .calibrate (X_calib , y_calib )
@@ -155,12 +157,12 @@ def send_to_human(X, lambda_1, lambda_2):
155157for 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
160162fig , ax = plt .subplots (figsize = (16 , 12 ))
161163im = ax .imshow (matrix )
162164ax .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 ))
164166ax .set_title ("Validated parameters" )
165167fig .tight_layout ()
166168plt .show ()
0 commit comments