flexible loss for classification More...
#include <shark/ObjectiveFunctions/Loss/DiscreteLoss.h>
Public Member Functions | |
SHARK_EXPORT_SYMBOL | DiscreteLoss (RealMatrix const &cost) |
std::string | name () const |
From INameable: return the class name. More... | |
SHARK_EXPORT_SYMBOL double | eval (BatchLabelType const &target, BatchOutputType const &prediction) const |
inherited from AbstractLoss, evaluation of the loss function More... | |
SHARK_EXPORT_SYMBOL void | defineCostMatrix (RealMatrix const &cost) |
SHARK_EXPORT_SYMBOL void | defineBalancedCost (UnlabeledData< unsigned int > const &labels) |
Public Member Functions inherited from shark::AbstractLoss< unsigned int, unsigned int > | |
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, unsigned int > | |
virtual | ~AbstractCost () |
const Features & | features () 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 () |
Protected Attributes | |
RealMatrix | m_cost |
cost matrix More... | |
Protected Attributes inherited from shark::AbstractCost< unsigned int, unsigned int > | |
Features | m_features |
Additional Inherited Members | |
Public Types inherited from shark::AbstractLoss< unsigned int, unsigned int > | |
typedef unsigned int | 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, unsigned int > | |
enum | Feature |
list of features a cost function can have More... | |
typedef unsigned int | OutputType |
typedef unsigned int | LabelType |
typedef Batch< OutputType >::type | BatchOutputType |
typedef Batch< LabelType >::type | BatchLabelType |
typedef TypedFlags< Feature > | Features |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
flexible loss for classification
Definition at line 57 of file DiscreteLoss.h.
SHARK_EXPORT_SYMBOL shark::DiscreteLoss::DiscreteLoss | ( | RealMatrix const & | cost | ) |
Constructor
cost | cost matrix in the format (target, prediction). |
SHARK_EXPORT_SYMBOL void shark::DiscreteLoss::defineBalancedCost | ( | UnlabeledData< unsigned int > const & | labels | ) |
Define a new cost structure so that the cost of misclassifying a pattern is anti-proportional to the frequency of its class. This amounts to balancing the class-wise cost in unbalanced data sets (i.e., where one class is far more frequent than another).
labels | label set to which the balanced loss should be adapted |
Referenced by name().
SHARK_EXPORT_SYMBOL void shark::DiscreteLoss::defineCostMatrix | ( | RealMatrix const & | cost | ) |
Define a new cost structure given by an explicit cost matrix.
cost | cost matrix in the format (target, prediction). |
Referenced by name().
|
virtual |
inherited from AbstractLoss, evaluation of the loss function
Implements shark::AbstractLoss< unsigned int, unsigned int >.
Referenced by name().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 67 of file DiscreteLoss.h.
References defineBalancedCost(), defineCostMatrix(), eval(), and SHARK_EXPORT_SYMBOL.
|
protected |
cost matrix
Definition at line 88 of file DiscreteLoss.h.