shark::AbstractCost< LabelT, OutputT > Class Template Referenceabstract

Cost function interface. More...

#include <shark/ObjectiveFunctions/AbstractCost.h>

+ Inheritance diagram for shark::AbstractCost< LabelT, OutputT >:

Public Types

enum  Feature { HAS_FIRST_DERIVATIVE = 1, HAS_SECOND_DERIVATIVE = 2, IS_LOSS_FUNCTION = 4 }
 list of features a cost function can have More...
 
typedef OutputT OutputType
 
typedef LabelT LabelType
 
typedef Batch< OutputType >::type BatchOutputType
 
typedef Batch< LabelType >::type BatchLabelType
 
typedef TypedFlags< FeatureFeatures
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 

Public Member Functions

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...
 
virtual double eval (Data< LabelType > const &targets, Data< OutputType > const &predictions) const =0
 
double operator() (Data< LabelType > const &targets, Data< OutputType > const &predictions) const
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
virtual std::string name () const
 returns the name of the object More...
 

Protected Attributes

Features m_features
 

Detailed Description

template<class LabelT, class OutputT = LabelT>
class shark::AbstractCost< LabelT, OutputT >

Cost function interface.

In Shark a cost function encodes the severity of a deviation of predictions from targets. This concept is more general than that or a loss function, because it does not necessarily amount to (uniformly) averaging a loss function over samples. In general, the loss depends on the true (training) label and the prediction in a not necessarily symmetric way. Also, in the most general case predictions can be in a different format than labels. E.g., the model prediction could be a probability distribution, while the label is a single value.
The concept of an AbstractCost function is different from that encoded by the ErrorFunction class. A cost function compares model predictions to labels. It does not know about the model making the predictions, and thus it can not handle LabeledData directly. However, it is one of the components necessary to process LabeledData in an ErrorFunction.

Definition at line 68 of file AbstractCost.h.

Member Typedef Documentation

◆ BatchLabelType

template<class LabelT, class OutputT = LabelT>
typedef Batch<LabelType>::type shark::AbstractCost< LabelT, OutputT >::BatchLabelType

Definition at line 74 of file AbstractCost.h.

◆ BatchOutputType

template<class LabelT, class OutputT = LabelT>
typedef Batch<OutputType>::type shark::AbstractCost< LabelT, OutputT >::BatchOutputType

Definition at line 73 of file AbstractCost.h.

◆ FeatureNotAvailableException

template<class LabelT, class OutputT = LabelT>
typedef TypedFeatureNotAvailableException<Feature> shark::AbstractCost< LabelT, OutputT >::FeatureNotAvailableException

Definition at line 86 of file AbstractCost.h.

◆ Features

template<class LabelT, class OutputT = LabelT>
typedef TypedFlags<Feature> shark::AbstractCost< LabelT, OutputT >::Features

Definition at line 86 of file AbstractCost.h.

◆ LabelType

template<class LabelT, class OutputT = LabelT>
typedef LabelT shark::AbstractCost< LabelT, OutputT >::LabelType

Definition at line 72 of file AbstractCost.h.

◆ OutputType

template<class LabelT, class OutputT = LabelT>
typedef OutputT shark::AbstractCost< LabelT, OutputT >::OutputType

Definition at line 71 of file AbstractCost.h.

Member Enumeration Documentation

◆ Feature

template<class LabelT, class OutputT = LabelT>
enum shark::AbstractCost::Feature

list of features a cost function can have

Enumerator
HAS_FIRST_DERIVATIVE 
HAS_SECOND_DERIVATIVE 
IS_LOSS_FUNCTION 

Definition at line 80 of file AbstractCost.h.

Constructor & Destructor Documentation

◆ ~AbstractCost()

template<class LabelT, class OutputT = LabelT>
virtual shark::AbstractCost< LabelT, OutputT >::~AbstractCost ( )
inlinevirtual

Definition at line 76 of file AbstractCost.h.

Member Function Documentation

◆ eval()

◆ features()

template<class LabelT, class OutputT = LabelT>
const Features& shark::AbstractCost< LabelT, OutputT >::features ( ) const
inline

Definition at line 86 of file AbstractCost.h.

◆ hasFirstDerivative()

template<class LabelT, class OutputT = LabelT>
bool shark::AbstractCost< LabelT, OutputT >::hasFirstDerivative ( ) const
inline

returns true when the first parameter derivative is implemented

Definition at line 89 of file AbstractCost.h.

◆ isLossFunction()

template<class LabelT, class OutputT = LabelT>
bool shark::AbstractCost< LabelT, OutputT >::isLossFunction ( ) const
inline

returns true when the cost function is in fact a loss function

Definition at line 98 of file AbstractCost.h.

◆ operator()()

template<class LabelT, class OutputT = LabelT>
double shark::AbstractCost< LabelT, OutputT >::operator() ( Data< LabelType > const &  targets,
Data< OutputType > const &  predictions 
) const
inline

Definition at line 107 of file AbstractCost.h.

◆ updateFeatures()

template<class LabelT, class OutputT = LabelT>
virtual void shark::AbstractCost< LabelT, OutputT >::updateFeatures ( )
inlinevirtual

Definition at line 86 of file AbstractCost.h.

Member Data Documentation

◆ m_features


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