shark::ZeroOneLoss< unsigned int, RealVector > Class Template Reference

0-1-loss for classification. More...

#include <shark/ObjectiveFunctions/Loss/ZeroOneLoss.h>

+ Inheritance diagram for shark::ZeroOneLoss< unsigned int, RealVector >:

Public Types

typedef base_type::BatchLabelType BatchLabelType
 
typedef base_type::BatchOutputType BatchOutputType
 
- Public Types inherited from shark::AbstractLoss< unsigned int, RealVector >
typedef RealVector OutputType
 
typedef unsigned int LabelType
 
typedef RealMatrix MatrixType
 
typedef Batch< OutputType >::type BatchOutputType
 
typedef Batch< LabelType >::type BatchLabelType
 
typedef ConstProxyReference< LabelType const >::type ConstLabelReference
 Const references to LabelType. More...
 
typedef ConstProxyReference< OutputType const >::type ConstOutputReference
 Const references to OutputType. More...
 
- Public Types inherited from shark::AbstractCost< unsigned int, RealVector >
enum  Feature
 list of features a cost function can have More...
 
typedef RealVector OutputType
 
typedef unsigned int LabelType
 
typedef Batch< OutputType >::type BatchOutputType
 
typedef Batch< LabelType >::type BatchLabelType
 
typedef TypedFlags< FeatureFeatures
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 

Public Member Functions

 ZeroOneLoss (double threshold=0.0)
 
std::string name () const
 From INameable: return the class name. More...
 
double eval (BatchLabelType const &labels, BatchOutputType const &predictions) const
 
double eval (Data< LabelType > const &targets, Data< OutputType > const &predictions, RealVector const &weights) const
 
- Public Member Functions inherited from shark::AbstractLoss< unsigned int, RealVector >
 AbstractLoss ()
 
virtual double eval (ConstLabelReference target, ConstOutputReference prediction) const
 evaluate the loss for a target and a prediction More...
 
double eval (Data< LabelType > const &targets, Data< OutputType > const &predictions) const
 
virtual double evalDerivative (ConstLabelReference target, ConstOutputReference prediction, OutputType &gradient) const
 evaluate the loss and its derivative for a target and a prediction More...
 
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 More...
 
virtual double evalDerivative (BatchLabelType const &target, BatchOutputType const &prediction, BatchOutputType &gradient) const
 evaluate the loss and the derivative w.r.t. the prediction More...
 
double operator() (LabelType const &target, OutputType const &prediction) const
 evaluate the loss for a target and a prediction More...
 
double operator() (BatchLabelType const &target, BatchOutputType const &prediction) const
 
- Public Member Functions inherited from shark::AbstractCost< unsigned int, RealVector >
virtual ~AbstractCost ()
 
const Featuresfeatures () const
 
virtual void updateFeatures ()
 
bool hasFirstDerivative () const
 returns true when the first parameter derivative is implemented More...
 
bool isLossFunction () const
 returns true when the cost function is in fact a loss function More...
 
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< unsigned int, RealVector >
Features m_features
 

Detailed Description

template<>
class shark::ZeroOneLoss< unsigned int, RealVector >

0-1-loss for classification.

Definition at line 85 of file ZeroOneLoss.h.

Member Typedef Documentation

◆ BatchLabelType

typedef base_type::BatchLabelType shark::ZeroOneLoss< unsigned int, RealVector >::BatchLabelType

Definition at line 89 of file ZeroOneLoss.h.

◆ BatchOutputType

typedef base_type::BatchOutputType shark::ZeroOneLoss< unsigned int, RealVector >::BatchOutputType

Definition at line 90 of file ZeroOneLoss.h.

Constructor & Destructor Documentation

◆ ZeroOneLoss()

shark::ZeroOneLoss< unsigned int, RealVector >::ZeroOneLoss ( double  threshold = 0.0)
inline

constructor

Parameters
thresholdin the case dim(predictions) == 1, predictions strictly larger than this parameter are regarded as belonging to the positive class

Definition at line 95 of file ZeroOneLoss.h.

Member Function Documentation

◆ eval() [1/2]

double shark::ZeroOneLoss< unsigned int, RealVector >::eval ( BatchLabelType const &  labels,
BatchOutputType const &  predictions 
) const
inlinevirtual

Return zero if labels == arg max { predictions_i } and one otherwise, where the index i runs over the components of the predictions vector. A special version of dim(predictions) == 1 computes the predicted labels by thresholding at zero. Shark's label convention is used, saying that a positive value encodes class 0, a negative value encodes class 1.

Implements shark::AbstractLoss< unsigned int, RealVector >.

Definition at line 114 of file ZeroOneLoss.h.

References SIZE_CHECK.

Referenced by main().

◆ eval() [2/2]

double shark::ZeroOneLoss< unsigned int, RealVector >::eval ( Data< LabelType > const &  targets,
Data< OutputType > const &  predictions,
RealVector const &  weights 
) const
inline

◆ name()

std::string shark::ZeroOneLoss< unsigned int, RealVector >::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 101 of file ZeroOneLoss.h.

References shark::AbstractLoss< LabelType, LabelType >::eval().

Referenced by main().


The documentation for this class was generated from the following file: