#NEWLINE# def compute_theil_on_bins( y_pred , mask , bin_indices , target_efficiencies , sample_weight ) : #NEWLINE# #INDENT# y_pred = column_or_1d ( y_pred ) #NEWLINE# sample_weight = check_sample_weight ( y_pred , sample_weight = sample_weight ) #NEWLINE# y_pred = y_pred [ mask ] #NEWLINE# bin_indices = bin_indices [ mask ] #NEWLINE# sample_weight = sample_weight [ mask ] #NEWLINE# bin_weights = compute_bin_weights ( bin_indices = bin_indices , sample_weight = sample_weight ) #NEWLINE# cuts = compute_cut_for_efficiency ( target_efficiencies , mask = numpy . ones ( len ( y_pred ) , dtype = bool ) , y_pred = y_pred , sample_weight = sample_weight ) #NEWLINE# result = 0.0 #NEWLINE# for cut in cuts : #NEWLINE# #INDENT# bin_efficiencies = compute_bin_efficiencies ( y_pred , bin_indices = bin_indices , cut = cut , sample_weight = sample_weight ) #NEWLINE# result += theil ( bin_efficiencies , weights = bin_weights ) #NEWLINE# #UNINDENT# return ( result / len ( cuts ) )