File prediction_complete.hpp

class CompletePrediction : public VectorDecorator<AllocatedVector<float64>>, public IEvaluatedPrediction
#include <prediction_complete.hpp>

Stores the scores that are predicted by a rule that predicts for all available labels.

Public Types

typedef View<float64>::iterator value_iterator

An iterator that provides access to the predicted scores and allows to modify them.

typedef View<float64>::const_iterator value_const_iterator

An iterator that provides read-only access to the predicted scores.

typedef CompleteIndexVector::const_iterator index_const_iterator

An iterator that provides read-only access to the indices of the labels for which the rule predicts.

Public Functions

CompletePrediction(uint32 numElements)
Parameters:

numElements – The number of labels for which the rule predicts

value_iterator values_begin()

Returns a value_iterator to the beginning of the predicted scores.

Returns:

A value_iterator to the beginning

value_iterator values_end()

Returns a value_iterator to the end of the predicted scores.

Returns:

A value_iterator to the end

value_const_iterator values_cbegin() const

Returns a value_const_iterator to the beginning of the predicted scores.

Returns:

A value_const_iterator to the beginning

value_const_iterator values_cend() const

Returns a const_iterator to the end of the predicted scores.

Returns:

A const_iterator to the end

index_const_iterator indices_cbegin() const

Returns an index_const_iterator to the beginning of the indices of the labels for which the rule predicts.

Returns:

An index_const_iterator to the beginning

index_const_iterator indices_cend() const

Returns an index_const_iterator to the end of the indices of the labels for which the rule predicts.

Returns:

An index_const_iterator to the end

virtual uint32 getNumElements() const override

Returns the number of indices.

Returns:

The number of indices

virtual void sort() override

Sorts the scores that are stored by this prediction in increasing order by the indices of the labels they correspond to.

virtual void postProcess(const IPostProcessor &postProcessor) override

Post-processes the scores that are stored by this prediction.

Parameters:

postProcessor – A reference to an object of type IPostProcessor that sould be used for post-processing

virtual void set(View<float64>::const_iterator begin, View<float64>::const_iterator end) final override

Sets the scores that are stored by this prediction to the values in a given iterator.

Parameters:
  • begin – An iterator to the beginning of the values to be set

  • end – An iterator to the end of the values to be set

virtual void set(BinnedConstIterator<float64> begin, BinnedConstIterator<float64> end) final override

Sets the scores that are stored by this prediction to the values in a given iterator.

Parameters:
  • begin – An iterator to the beginning of the values to be set

  • end – An iterator to the end of the values to be set

virtual bool isPartial() const override

Returns whether the indices are partial, i.e., some indices in the range [0, getNumElements()) are missing, or not.

Returns:

True, if the indices are partial, false otherwise

virtual uint32 getIndex(uint32 pos) const override

Returns the index at a specific position.

Parameters:

pos – The position of the index. Must be in [0, getNumElements())

Returns:

The index at the given position

virtual std::unique_ptr<IStatisticsSubset> createStatisticsSubset(const IStatistics &statistics, const EqualWeightVector &weights) const override

Creates and returns a new subset of the given statistics that only contains the labels whose indices are stored in this vector.

Parameters:
  • statistics – A reference to an object of type IStatistics that should be used to create the subset

  • weights – A reference to an object of type EqualWeightVector that provides access to the weights of individual training examples

Returns:

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

virtual std::unique_ptr<IStatisticsSubset> createStatisticsSubset(const IStatistics &statistics, const BitWeightVector &weights) const override

Creates and returns a new subset of the given statistics that only contains the labels whose indices are stored in this vector.

Parameters:
  • statistics – A reference to an object of type IStatistics that should be used to create the subset

  • weights – A reference to an object of type BitWeightVector that provides access to the weights of individual training examples

Returns:

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

virtual std::unique_ptr<IStatisticsSubset> createStatisticsSubset(const IStatistics &statistics, const DenseWeightVector<uint32> &weights) const override

Creates and returns a new subset of the given statistics that only contains the labels whose indices are stored in this vector.

Parameters:
  • statistics – A reference to an object of type IStatistics that should be used to create the subset

  • weights – A reference to an object of type DenseWeightVector<uint32> that provides access to the weights of individual training examples

Returns:

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

virtual std::unique_ptr<IStatisticsSubset> createStatisticsSubset(const IStatistics &statistics, const OutOfSampleWeightVector<EqualWeightVector> &weights) const override

Creates and returns a new subset of the given statistics that only contains the labels whose indices are stored in this vector.

Parameters:
  • statistics – A reference to an object of type IStatistics that should be used to create the subset

  • weights – A reference to an object of type OutOfSampleWeightVector<EqualWeightVector> that provides access to the weights of individual training examples

Returns:

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

virtual std::unique_ptr<IStatisticsSubset> createStatisticsSubset(const IStatistics &statistics, const OutOfSampleWeightVector<BitWeightVector> &weights) const override

Creates and returns a new subset of the given statistics that only contains the labels whose indices are stored in this vector.

Parameters:
  • statistics – A reference to an object of type IStatistics that should be used to create the subset

  • weights – A reference to an object of type OutOfSampleWeightVector<BitWeightVector> that provides access to the weights of individual training examples

Returns:

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

virtual std::unique_ptr<IStatisticsSubset> createStatisticsSubset(const IStatistics &statistics, const OutOfSampleWeightVector<DenseWeightVector<uint32>> &weights) const override

Creates and returns a new subset of the given statistics that only contains the labels whose indices are stored in this vector.

Parameters:
  • statistics – A reference to an object of type IStatistics that should be used to create the subset

  • weights – A reference to an object of type OutOfSampleWeightVector<DenseWeightVector<uint32>> that provides access to the weights of individual training examples

Returns:

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

virtual std::unique_ptr<IRuleRefinement> createRuleRefinement(IFeatureSubspace &featureSubspace, uint32 featureIndex) const override

Creates and return a new instance of type IRuleRefinement that allows to search for the best refinement of an existing rule that predicts only for the labels whose indices are stored in this vector.

Parameters:
  • featureSubspace – A reference to an object of type IFeatureSubspace that should be to search for the refinement

  • featureIndex – The index of the feature that should be considered when searching for the refinement

Returns:

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

virtual void apply(IStatistics &statistics, uint32 statisticIndex) const override

Updates given statistics by applying this prediction.

Parameters:
  • statistics – A reference to an object of type IStatistics to be updated

  • statisticIndex – The index of the statistic to be updated

virtual void revert(IStatistics &statistics, uint32 statisticIndex) const override

Updates given statistics by reverting this prediction.

Parameters:
  • statistics – A reference to an object of type IStatistics to be updated

  • statisticIndex – The index of the statistic to be updated

virtual std::unique_ptr<IHead> createHead() const override

Creates and returns a head that contains the scores that are stored by this prediction.

Returns:

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

Private Members

const CompleteIndexVector indexVector_