flexible loss for classification More...
#include <shark/ObjectiveFunctions/Loss/DiscreteLoss.h>
 Inheritance diagram for shark::DiscreteLoss:
 Inheritance diagram for shark::DiscreteLoss:| Public Member Functions | |
| SHARK_EXPORT_SYMBOL | DiscreteLoss (RealMatrix const &cost) | 
| std::string | name () const | 
| From INameable: return the class name. | |
| SHARK_EXPORT_SYMBOL double | eval (BatchLabelType const &target, BatchOutputType const &prediction) const | 
| inherited from AbstractLoss, evaluation of the loss function | |
| 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 | |
| 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 | |
| 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 | |
| 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 () | 
| Protected Attributes | |
| RealMatrix | m_cost | 
| cost matrix | |
|  Protected Attributes inherited from shark::AbstractCost< LabelT, OutputT > | |
| 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< LabelTypeconst >::type | ConstLabelReference | 
| Const references to LabelType. | |
| typedef ConstProxyReference< OutputTypeconst >::type | ConstOutputReference | 
| Const references to OutputType. | |
|  Public Types inherited from shark::AbstractCost< LabelT, OutputT > | |
| 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< 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 | 
| 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). | 
| 
 | virtual | 
inherited from AbstractLoss, evaluation of the loss function
Implements shark::AbstractLoss< unsigned int, unsigned int >.
| 
 | inlinevirtual | 
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 67 of file DiscreteLoss.h.
| 
 | protected | 
cost matrix
Definition at line 88 of file DiscreteLoss.h.