squared loss for regression and classification More...
#include <shark/ObjectiveFunctions/Loss/SquaredLoss.h>
Public Types | |
typedef base_type::BatchOutputType | BatchOutputType |
typedef base_type::BatchLabelType | BatchLabelType |
![]() | |
typedef OutputType | OutputType |
typedef LabelType | LabelType |
typedef VectorMatrixTraits< OutputType >::DenseMatrixType | MatrixType |
typedef Batch< OutputType >::type | BatchOutputType |
typedef Batch< LabelType >::type | BatchLabelType |
![]() | |
enum | Feature |
list of features a cost function can have More... | |
typedef OutputType | OutputType |
typedef LabelType | LabelType |
typedef Batch< OutputType >::type | BatchOutputType |
typedef Batch< LabelType >::type | BatchLabelType |
typedef TypedFlags< Feature > | Features |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
Public Member Functions | |
SquaredLoss () | |
Constructor. More... | |
std::string | name () const |
From INameable: return the class name. More... | |
double | eval (BatchLabelType const &labels, BatchOutputType const &predictions) const |
Evaluate the squared loss \( (label - prediction)^2 \). More... | |
double | evalDerivative (BatchLabelType const &label, BatchOutputType const &prediction, BatchOutputType &gradient) const |
![]() | |
AbstractLoss () | |
virtual double | eval (LabelType const &target, OutputType const &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 (LabelType const &target, OutputType const &prediction, OutputType &gradient) const |
evaluate the loss and its derivative for a target and a prediction More... | |
virtual double | evalDerivative (LabelType const &target, OutputType const &prediction, OutputType &gradient, MatrixType &hessian) const |
evaluate the loss and its first and second derivative for a target and a 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 |
![]() | |
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 |
![]() | |
virtual | ~INameable () |
Additional Inherited Members | |
![]() | |
Features | m_features |
squared loss for regression and classification
The SquaredLoss computes the squared distance between target and prediction. It is defined for both vectorial as well as integral labels. In the case of integral labels, the label c is interpreted as unit-vector having the c-th component activated.
Definition at line 48 of file SquaredLoss.h.
typedef base_type::BatchLabelType shark::SquaredLoss< OutputType, LabelType >::BatchLabelType |
Definition at line 53 of file SquaredLoss.h.
typedef base_type::BatchOutputType shark::SquaredLoss< OutputType, LabelType >::BatchOutputType |
Definition at line 52 of file SquaredLoss.h.
|
inline |
Constructor.
Definition at line 56 of file SquaredLoss.h.
References shark::AbstractCost< LabelType, OutputType >::HAS_FIRST_DERIVATIVE, and shark::AbstractCost< LabelType, OutputType >::m_features.
|
inlinevirtual |
Evaluate the squared loss \( (label - prediction)^2 \).
Implements shark::AbstractLoss< LabelType, OutputType >.
Definition at line 69 of file SquaredLoss.h.
References shark::blas::distanceSqr(), shark::blas::row(), and SIZE_CHECK.
Referenced by shark::CARTClassifier< RealVector >::computeFeatureImportances(), shark::CARTClassifier< RealVector >::computeOOBerror(), shark::SquaredLoss< OutputType, LabelType >::evalDerivative(), shark::SquaredLoss< OutputType, unsigned int >::evalDerivative(), and main().
|
inlinevirtual |
Evaluate the squared loss \( (label - prediction)^2 \) and its deriative \( \frac{\partial}{\partial prediction} 1/2 (label - prediction)^2 = prediction - label \).
Reimplemented from shark::AbstractLoss< LabelType, OutputType >.
Definition at line 82 of file SquaredLoss.h.
References shark::SquaredLoss< OutputType, LabelType >::eval(), and shark::blas::noalias().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 63 of file SquaredLoss.h.
References shark::AbstractLoss< LabelType, OutputType >::eval().