Description
I was going through the wikipedia pages as well as other library implementations of loss functions to implement standalone loss functions and their gradients under ml/base/loss/float64/*.
I noticed a possible bug in _modifiedHuberLoss function implemented under ml/incr/binary-classification
Current implementation:
setReadOnly( Model.prototype, '_modifiedHuberLoss', function modifiedHuber( x, y ) {
var eta;
var d;
eta = this[ this._learningRateMethod ]();
this._regularize( eta );
d = y * this._dot( x.data, x.strides[ 0 ], x.offset );
if ( d < -1.0 ) {
this._add( x, 4.0*eta*y );
} else {
this._add( x, eta*( y-(d*y) ) );
}
return this;
});
Link
I believe in the else branch, it should be this._add( x, eta*2*( y-(d*y) ) ) instead of this._add( x, eta*( y-(d*y) ) ). That is, it seems like it is missing a multiplication with 2 here.
References:
Wikipedia
sklearn
cc: @Planeshifter
Related Issues
No response
Questions
No.
Demo
No response
Reproduction
Expected Results
$$\frac{\partial \ell}{\partial p} =
\begin{cases}
-4y & \text{if } yp < -1 \\\
-2y(1 - yp) & \text{if } -1 \le yp \le 1 \\\
0 & \text{if } yp > 1
\end{cases}$$
Actual Results
Version
No response
Environments
N/A
Browser Version
No response
Node.js / npm Version
No response
Platform
No response
Checklist
Description
I was going through the wikipedia pages as well as other library implementations of loss functions to implement standalone loss functions and their gradients under
ml/base/loss/float64/*.I noticed a possible bug in
_modifiedHuberLossfunction implemented underml/incr/binary-classificationCurrent implementation:
Link
I believe in the
elsebranch, it should bethis._add( x, eta*2*( y-(d*y) ) )instead ofthis._add( x, eta*( y-(d*y) ) ). That is, it seems like it is missing a multiplication with 2 here.References:
Wikipedia
sklearn
cc: @Planeshifter
Related Issues
No response
Questions
No.
Demo
No response
Reproduction
Expected Results
Actual Results
Version
No response
Environments
N/A
Browser Version
No response
Node.js / npm Version
No response
Platform
No response
Checklist