#NEWLINE# def compute_theil_on_groups( y_pred , mask , groups_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# groups_weights = compute_group_weights ( groups_indices , sample_weight = sample_weight ) #NEWLINE# cuts = compute_cut_for_efficiency ( target_efficiencies , mask = mask , y_pred = y_pred , sample_weight = sample_weight ) #NEWLINE# result = 0.0 #NEWLINE# for cut in cuts : #NEWLINE# #INDENT# groups_efficiencies = compute_group_efficiencies ( y_pred , groups_indices , cut , sample_weight = sample_weight ) #NEWLINE# result += theil ( groups_efficiencies , groups_weights ) #NEWLINE# #UNINDENT# return ( result / len ( cuts ) )