ModErn Text Analysis
META Enumerates Textual Applications
|
The hinge loss for SGD algorithms. More...
#include <hinge.h>
Public Member Functions | |
double | loss (double prediction, int expected) const override |
The loss incurred in assigning the given prediction value, given the correct value of the prediction. More... | |
double | derivative (double prediction, int expected) const override |
The derivative of the loss function given a predicted value and the expected result of that prediction. More... | |
Static Public Attributes | |
static const std::string | id = "hinge" |
The identifier for this loss function. | |
The hinge loss for SGD algorithms.
Defined as \(\phi(p, y) = \max(0,1-py)\), with \(\phi^\prime(p,y) = -y\) if \(py < 1\), 0 otherwise. (Technically, the derivative doesn't always exist for straight hinge-loss, so this is a subgradient approach. You can avoid this problem by using a smoothed version of the hinge loss, like smooth_hinge).
|
overridevirtual |
The loss incurred in assigning the given prediction value, given the correct value of the prediction.
prediction | The prediction obtained from the model (dot product) |
expected | The expected (as in, correct) value of the model's prediction |
Implements meta::classify::loss::loss_function.
|
overridevirtual |
The derivative of the loss function given a predicted value and the expected result of that prediction.
prediction | The prediction obtained from the model (dot product) |
expected | The expected (as in, correct) value of the model's prediction |
Implements meta::classify::loss::loss_function.