#NEWLINE# def __call__( self , y , pred , sample_weight = None ) : #NEWLINE# #INDENT# pred = pred . ravel ( ) #NEWLINE# diff = ( y - pred ) #NEWLINE# alpha = self . alpha #NEWLINE# mask = ( y > pred ) #NEWLINE# if ( sample_weight is None ) : #NEWLINE# #INDENT# loss = ( ( ( alpha * diff [ mask ] . sum ( ) ) + ( ( 1.0 - alpha ) * diff [ ( ~ mask ) ] . sum ( ) ) ) / y . shape [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# loss = ( ( ( alpha * np . sum ( ( sample_weight [ mask ] * diff [ mask ] ) ) ) + ( ( 1.0 - alpha ) * np . sum ( ( sample_weight [ ( ~ mask ) ] * diff [ ( ~ mask ) ] ) ) ) ) / sample_weight . sum ( ) ) #NEWLINE# #UNINDENT# return loss