Hinge loss for binary classification for a single example. Hinge loss equals max(0, 1 - y * wx) (see https://en.wikipedia.org/wiki/Hinge_loss). For weighted instances loss should be multiplied by the instance weight.
| 87 | // equals max(0, 1 - y * wx) (see https://en.wikipedia.org/wiki/Hinge_loss). |
| 88 | // For weighted instances loss should be multiplied by the instance weight. |
| 89 | double ComputePrimalLoss(const double wx, const double example_label, |
| 90 | const double example_weight) const final { |
| 91 | const double y_wx = example_label * wx; |
| 92 | return std::max(0.0, 1 - y_wx) * example_weight; |
| 93 | } |
| 94 | |
| 95 | double PrimalLossDerivative(const double wx, const double label, |
| 96 | const double example_weight) const final { |