0-1-loss for classification. More...
#include <shark/ObjectiveFunctions/Loss/ZeroOneLoss.h>
Public Member Functions | |
ZeroOneLoss () | |
constructor | |
std::string | name () const |
From INameable: return the class name. | |
double | eval (BatchLabelType const &labels, BatchOutputType const &predictions) const |
Return zero if labels == predictions and one otherwise. | |
virtual double | eval (BatchLabelType const &target, BatchOutputType const &prediction) const=0 |
evaluate the loss for a batch of targets and a prediction | |
virtual double | eval (ConstLabelReference target, ConstOutputReference prediction) const |
evaluate the loss for a target and a prediction | |
double | eval (Data< LabelType > const &targets, Data< OutputType > const &predictions) const |
Public Member Functions inherited from shark::AbstractLoss< LabelT, OutputT > | |
AbstractLoss () | |
virtual double | evalDerivative (ConstLabelReference target, ConstOutputReference prediction, OutputType &gradient) const |
evaluate the loss and its derivative for a target and a prediction | |
virtual double | evalDerivative (ConstLabelReference target, ConstOutputReference prediction, OutputType &gradient, MatrixType &hessian) const |
evaluate the loss and its first and second derivative for a target and a prediction | |
virtual double | evalDerivative (BatchLabelType const &target, BatchOutputType const &prediction, BatchOutputType &gradient) const |
evaluate the loss and the derivative w.r.t. the prediction | |
double | operator() (LabelType const &target, OutputType const &prediction) const |
evaluate the loss for a target and a prediction | |
double | operator() (BatchLabelType const &target, BatchOutputType const &prediction) const |
Public Member Functions inherited from shark::AbstractCost< LabelT, OutputT > | |
virtual | ~AbstractCost () |
const Features & | features () const |
virtual void | updateFeatures () |
bool | hasFirstDerivative () const |
returns true when the first parameter derivative is implemented | |
bool | isLossFunction () const |
returns true when the cost function is in fact a loss function | |
double | operator() (Data< LabelType > const &targets, Data< OutputType > const &predictions) const |
Public Member Functions inherited from shark::INameable | |
virtual | ~INameable () |
Additional Inherited Members | |
Protected Attributes inherited from shark::AbstractCost< LabelT, OutputT > | |
Features | m_features |
0-1-loss for classification.
The ZeroOneLoss requires the existence of the comparison operator == for its LabelType template parameter. The loss function returns zero of the predictions exactly matches the label, and one otherwise.
Definition at line 51 of file ZeroOneLoss.h.
typedef base_type::BatchLabelType shark::ZeroOneLoss< LabelType, OutputType >::BatchLabelType |
Definition at line 55 of file ZeroOneLoss.h.
typedef base_type::BatchOutputType shark::ZeroOneLoss< LabelType, OutputType >::BatchOutputType |
Definition at line 56 of file ZeroOneLoss.h.
|
inline |
constructor
Definition at line 59 of file ZeroOneLoss.h.
|
inlinevirtual |
Return zero if labels == predictions and one otherwise.
Implements shark::AbstractLoss< LabelT, OutputT >.
Definition at line 70 of file ZeroOneLoss.h.
References SIZE_CHECK.
Referenced by main(), main(), and run_one_trial().
|
virtual |
evaluate the loss for a batch of targets and a prediction
target | target values |
prediction | predictions, typically made by a model |
Implements shark::AbstractLoss< LabelT, OutputT >.
|
inlinevirtual |
evaluate the loss for a target and a prediction
target | target value |
prediction | prediction, typically made by a model |
Reimplemented from shark::AbstractLoss< LabelT, OutputT >.
Definition at line 92 of file AbstractLoss.h.
|
inlinevirtual |
from AbstractCost
targets | target values |
predictions | predictions, typically made by a model |
Reimplemented from shark::AbstractLoss< LabelT, OutputT >.
Definition at line 149 of file AbstractLoss.h.
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 64 of file ZeroOneLoss.h.