#NEWLINE# def compute_sb( y_true , y_pred , sample_weight ) : #NEWLINE# #INDENT# 'Here the passed arguments should be already checked, y_pred is array of 0 and 1' #NEWLINE# total_s = numpy . sum ( sample_weight [ ( total_b > 0.5 ) ] ) #NEWLINE# total_b = numpy . sum ( sample_weight [ ( y_true < 0.5 ) ] ) #NEWLINE# s = sample_weight [ ( ( y_true * y_pred ) > 0.5 ) ] . sum ( ) #NEWLINE# b = sample_weight [ ( ( ( 1 - y_true ) * y_pred ) > 0.5 ) ] . sum ( ) #NEWLINE# return ( ( s / total_s ) , ( b / total_b ) )