File loss_decomposable_sparse.hpp

namespace boosting
template<typename StatisticType>
class ISparseDecomposableClassificationLoss : public virtual boosting::IDecomposableClassificationLoss<StatisticType>, public ISparseEvaluationMeasure<StatisticType>
#include <loss_decomposable_sparse.hpp>

Defines an interface for all decomposable loss functions that are suited for the use of sparse data structures. To meet this requirement, the gradients and Hessians that are computed by the loss function should be zero, if the prediction for a label is correct.

Template Parameters:

StatisticType – The type of the gradients and Hessians that are calculated by the loss function

Public Functions

inline virtual ~ISparseDecomposableClassificationLoss() override
virtual void updateDecomposableStatistics(uint32 exampleIndex, const CContiguousView<const uint8> &labelMatrix, const SparseSetView<StatisticType> &scoreMatrix, CompleteIndexVector::const_iterator indicesBegin, CompleteIndexVector::const_iterator indicesEnd, SparseSetView<Statistic<StatisticType>> &statisticView) const = 0

Updates the statistics of the example at a specific index, considering only the labels, whose indices are provided by a CompleteIndexVector.

Parameters:
  • exampleIndex – The index of the example for which the gradients and Hessians should be updated

  • labelMatrix – A reference to an object of type CContiguousView that provides random access to the labels of the training examples

  • scoreMatrix – A reference to an object of type SparseSetView that stores the currently predicted scores

  • indicesBegin – A CompleteIndexVector::const_iterator to the beginning of the label indices

  • indicesEnd – A CompleteIndexVector::const_iterator to the end of the label indices

  • statisticView – A reference to an object of type SparseSetView to be updated

virtual void updateDecomposableStatistics(uint32 exampleIndex, const CContiguousView<const uint8> &labelMatrix, const SparseSetView<StatisticType> &scoreMatrix, PartialIndexVector::const_iterator indicesBegin, PartialIndexVector::const_iterator indicesEnd, SparseSetView<Statistic<StatisticType>> &statisticView) const = 0

Updates the statistics of the example at a specific index, considering only the labels, whose indices are provided by a PartialIndexVector.

Parameters:
  • exampleIndex – The index of the example for which the gradients and Hessians should be updated

  • labelMatrix – A reference to an object of type CContiguousView that provides random access to the labels of the training examples

  • scoreMatrix – A reference to an object of type SparseSetView that stores the currently predicted scores

  • indicesBegin – A PartialIndexVector::const_iterator to the beginning of the label indices

  • indicesEnd – A PartialIndexVector::const_iterator to the end of the label indices

  • statisticView – A reference to an object of type SparseSetView to be updated

virtual void updateDecomposableStatistics(uint32 exampleIndex, const BinaryCsrView &labelMatrix, const SparseSetView<StatisticType> &scoreMatrix, CompleteIndexVector::const_iterator indicesBegin, CompleteIndexVector::const_iterator indicesEnd, SparseSetView<Statistic<StatisticType>> &statisticView) const = 0

Updates the statistics of the example at a specific index, considering only the labels, whose indices are provided by a CompleteIndexVector.

Parameters:
  • exampleIndex – The index of the example for which the gradients and Hessians should be updated

  • labelMatrix – A reference to an object of type BinaryCsrView that provides row-wise access to the labels of the training examples

  • scoreMatrix – A reference to an object of type SparseSetView that stores the currently predicted scores

  • indicesBegin – A CompleteIndexVector::const_iterator to the beginning of the label indices

  • indicesEnd – A CompleteIndexVector::const_iterator to the end of the label indices

  • statisticView – A reference to an object of type SparseSetView to be updated

virtual void updateDecomposableStatistics(uint32 exampleIndex, const BinaryCsrView &labelMatrix, const SparseSetView<StatisticType> &scoreMatrix, PartialIndexVector::const_iterator indicesBegin, PartialIndexVector::const_iterator indicesEnd, SparseSetView<Statistic<StatisticType>> &statisticView) const = 0

Updates the statistics of the example at a specific index, considering only the labels, whose indices are provided by a PartialIndexVector.

Parameters:
  • exampleIndex – The index of the example for which the gradients and Hessians should be updated

  • labelMatrix – A reference to an object of type BinaryCsrView that provides row-wise access to the labels of the training examples

  • scoreMatrix – A reference to an object of type SparseSetView that stores the currently predicted scores

  • indicesBegin – A PartialIndexVector::const_iterator to the beginning of the label indices

  • indicesEnd – A PartialIndexVector::const_iterator to the end of the label indices

  • statisticView – A reference to an object of type SparseSetView to be updated

template<typename StatisticType>
class ISparseDecomposableClassificationLossFactory : public virtual boosting::IDecomposableClassificationLossFactory<StatisticType>, public virtual ISparseEvaluationMeasureFactory<StatisticType>
#include <loss_decomposable_sparse.hpp>

Defines an interface for all factories that allow to create instances of the type ISparseDecomposableClassificationLoss.

Template Parameters:

StatisticType – The type of the gradients and Hessians that are calculated by the loss function

Public Functions

inline virtual ~ISparseDecomposableClassificationLossFactory() override
virtual std::unique_ptr<ISparseDecomposableClassificationLoss<StatisticType>> createSparseDecomposableClassificationLoss() const = 0

Creates and returns a new object of type ISparseDecomposableClassificationLoss.

Returns:

An unique pointer to an object of type ISparseDecomposableClassificationLoss that has been created

inline virtual std::unique_ptr<IDecomposableClassificationLoss<StatisticType>> createDecomposableClassificationLoss() const final override

inline std::unique_ptr<ISparseEvaluationMeasure<StatisticType>> createSparseEvaluationMeasure() const final override

See also

ISparseEvaluationMeasureFactory::createSparseEvaluationMeasure

class ISparseDecomposableClassificationLossConfig : public boosting::IDecomposableClassificationLossConfig
#include <loss_decomposable_sparse.hpp>

Defines an interface for all classes that allow to configure a decomposable loss function that is suited for the use of sparse data structures.

Subclassed by boosting::DecomposableSquaredHingeLossConfig

Public Functions

inline virtual ~ISparseDecomposableClassificationLossConfig() override
virtual std::unique_ptr<IPreset<float32>> createSparseDecomposable32BitClassificationPreset() const = 0

Creates and returns a new object of type IPreset<float32>.

Returns:

An unique pointer to an object of type IPreset<float32> that has been created

virtual std::unique_ptr<IPreset<float64>> createSparseDecomposable64BitClassificationPreset() const = 0

Creates and returns a new object of type IPreset<float64>.

Returns:

An unique pointer to an object of type IPreset<float64> that has been created

inline virtual std::unique_ptr<IDecomposableClassificationLossConfig::IPreset<float32>> createDecomposable32BitClassificationPreset() const final override

Creates and returns a new object of type IPreset<float32>.

Returns:

An unique pointer to an object of type IPreset<float32> that has been created

inline virtual std::unique_ptr<IDecomposableClassificationLossConfig::IPreset<float64>> createDecomposable64BitClassificationPreset() const final override

Creates and returns a new object of type IPreset<float64>.

Returns:

An unique pointer to an object of type IPreset<float64> that has been created

inline virtual bool isSparse() const final override

Returns whether the loss function supports to use a sparse format for storing statistics or not.

Returns:

True, if the loss function supports to use a sparse format for storing statistics, false otherwise

template<typename StatisticType>
class IPreset : public boosting::IDecomposableClassificationLossConfig::IPreset<StatisticType>
#include <loss_decomposable_sparse.hpp>

Provides access to the interface of an ISparseDecomposableClassificationLossConfig, abstracting away certain configuration options that have already been pre-determined.

Template Parameters:

StatisticType – The type that should be used for representing statistics

Public Functions

inline virtual ~IPreset() override
virtual std::unique_ptr<ISparseDecomposableClassificationLossFactory<StatisticType>> createSparseDecomposableClassificationLossFactory() const = 0

Creates and returns a new object of type ISparseDecomposableClassificationLossFactory according to the specified configuration.

Returns:

An unique pointer to an object of type ISparseDecomposableClassificationLossFactory that has been created

inline std::unique_ptr<ISparseEvaluationMeasureFactory<StatisticType>> createSparseEvaluationMeasureFactory() const

Creates and returns a new object of type ISparseEvaluationMeasureFactory according to the specified configuration.

Returns:

An unique pointer to an object of type ISparseEvaluationMeasureFactory that has been created

inline virtual std::unique_ptr<IDecomposableClassificationLossFactory<StatisticType>> createDecomposableClassificationLossFactory() const final override

Creates and returns a new object of type IDecomposableClassificationLossFactory according to the specified configuration.

Returns:

An unique pointer to an object of type IDecomposableClassificationLossFactory that has been created