Conjugate of hinge loss. This is computed as: \phi*(z) = z if z \in [-1, 0] and +infinity everywhere else. See for instance http://www.eecs.berkeley.edu/~wainwrig/stat241b/lec10.pdf Here we want the weighted version of the conjugate loss. It turns out, that if w is the weight of an example, the conjugate of the weighted hinge loss is given by: \phi*(z) = z if z \in [-w, 0] and +infinity everywhere
| 73 | // \phi_y*(z) = y*z if y*z \in [-w, 0] and +infinity everywhere else where |
| 74 | // y \in {-1,1}. The following method implements \phi_y*(-\alpha/w). |
| 75 | double ComputeDualLoss(const double current_dual, const double example_label, |
| 76 | const double example_weight) const final { |
| 77 | // For binary classification, there are 2 conjugate functions, one per |
| 78 | // label value (-1 and 1). |
| 79 | const double y_alpha = current_dual * example_label; // y \alpha |
| 80 | if (y_alpha < 0 || y_alpha > 1.0) { |
| 81 | return std::numeric_limits<double>::max(); |
| 82 | } |
| 83 | return -y_alpha * example_weight; |
| 84 | } |
| 85 | |
| 86 | // Hinge loss for binary classification for a single example. Hinge loss |
| 87 | // equals max(0, 1 - y * wx) (see https://en.wikipedia.org/wiki/Hinge_loss). |