public double deviance ( double w , double y , double f ) { switch ( distribution ) { case AUTO : case gaussian : return w * ( y - f ) * ( y - f ) ; // leads to wMSE case huber : if ( Math . abs ( y - f ) <= huberDelta ) { return w * ( y - f ) * ( y - f ) ; // same as wMSE } else { return 2 * w * ( Math . abs ( y - f ) - huberDelta ) * huberDelta ; // note quite the same as wMAE } case laplace : return w * Math . abs ( y - f ) ; // same as wMAE case quantile : return y > f ? w * quantileAlpha * ( y - f ) : w * ( 1 - quantileAlpha ) * ( f - y ) ; case bernoulli : // unused return - 2 * w * ( y * log ( f ) + ( 1 - y ) * log ( 1 - f ) ) ; case quasibinomial : // unused if ( y == f ) return 0 ; if ( f > 1 ) return - 2 * w * y * log ( f ) ; else if ( f < 0 ) return - 2 * w * ( 1 - y ) * log ( 1 - f ) ; else return - 2 * w * ( y * log ( f ) + ( 1 - y ) * log ( 1 - f ) ) ; case poisson : f = link ( f ) ; //bring back f to link space return - 2 * w * ( y * f - exp ( f ) ) ; case gamma : f = link ( f ) ; //bring back f to link space return 2 * w * ( y * exp ( - f ) + f ) ; case tweedie : f = link ( f ) ; //bring back f to link space assert ( tweediePower > 1 && tweediePower < 2 ) ; return 2 * w * ( Math . pow ( y , 2 - tweediePower ) / ( ( 1 - tweediePower ) * ( 2 - tweediePower ) ) - y * exp ( f * ( 1 - tweediePower ) ) / ( 1 - tweediePower ) + exp ( f * ( 2 - tweediePower ) ) / ( 2 - tweediePower ) ) ; case modified_huber : double yf = ( 2 * y - 1 ) * f ; if ( yf < - 1 ) return - w * 4 * yf ; else if ( yf > 1 ) return 0 ; else return w * yf * yf ; default : throw H2O . unimpl ( ) ; } }
Deviance of given distribution function at predicted value f