File prediction_partial.hpp¶
-
template<typename ScoreType>
class PartialPrediction : public VectorDecorator<ResizableVector<ScoreType>>, public IEvaluatedPrediction¶ - #include <prediction_partial.hpp>
Stores the scores that are predicted by a rule that predicts for a subset of the available outputs.
- Template Parameters:
ScoreType – The type of the predicted scores
Public Types
-
using value_iterator = View<ScoreType>::iterator¶
An iterator that provides access to the predicted scores and allows to modify them.
-
using value_const_iterator = View<ScoreType>::const_iterator¶
An iterator that provides read-only access to the predicted scores.
-
using index_iterator = PartialIndexVector::iterator¶
An iterator that provides access to the indices for which the rule predicts and allows to modify them.
-
using index_const_iterator = PartialIndexVector::const_iterator¶
An iterator that provides read-only access to the indices for which the rule predicts.
Public Functions
-
PartialPrediction(uint32 numElements, bool sorted, IStatisticsUpdateFactory<ScoreType> &statisticsUpdateFactory)¶
- Parameters:
numElements – The number of outputs for which the rule predicts
sorted – True, if the scores that are stored by this prediction are sorted in increasing order by the corresponding output indices, false otherwise
statisticsUpdateFactory – A reference to an object of type
IStatisticsUpdateFactory
-
value_iterator values_begin()¶
Returns a
value_iteratorto the beginning of the predicted scores.- Returns:
A
value_iteratorto the beginning
-
value_iterator values_end()¶
Returns a
value_iteratorto the end of the predicted scores.- Returns:
A
value_iteratorto the end
-
value_const_iterator values_cbegin() const¶
Returns a
value_const_iteratorto the beginning of the predicted scores.- Returns:
A
value_const_iteratorto the beginning
-
value_const_iterator values_cend() const¶
Returns a
const_iteratorto the end of the predicted scores.- Returns:
A
const_iteratorto the end
-
index_iterator indices_begin()¶
Returns an
index_iteratorto the beginning of the indices for which the rule predicts.- Returns:
An
index_iteratorto the beginning
-
index_iterator indices_end()¶
Returns an
index_iteratorto the end of the indices for which the rule predicts.- Returns:
An
index_iteratorto the end
-
index_const_iterator indices_cbegin() const¶
Returns an
index_const_iteratorto the beginning of the indices for which the rule predicts.- Returns:
An
index_const_iteratorto the beginning
-
index_const_iterator indices_cend() const¶
Returns an
index_const_iteratorto the end of the indices for which the rule predicts.- Returns:
An
index_const_iteratorto the end
-
void setSorted(bool sorted)¶
Sets whether the scores that are stored by this prediction are sorted in increasing order by the corresponding output indices, or not.
- Parameters:
sorted – True, if the scores that are stored by this prediction are sorted in increasing order by the corresponding output indices, false otherwise
-
void setNumElements(IStatisticsUpdateFactory<ScoreType> &statisticsUpdateFactory, uint32 numElements, bool freeMemory)¶
Sets the number of elements in the vector.
- Parameters:
statisticsUpdateFactory – A reference to an object of type
IStatisticsUpdateFactorynumElements – The number of elements to be set
freeMemory – True, if unused memory should be freed, if possible, false otherwise
-
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 outputs 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
IPostProcessorthat should be used for post-processing
-
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 void visit(PartialIndexVectorVisitor partialIndexVectorVisitor, CompleteIndexVectorVisitor completeIndexVectorVisitor) const override¶
Invokes one of the given visitor functions, depending on which one is able to handle this particular type of vector.
- Parameters:
partialIndexVectorVisitor – The visitor function for handling objects of the type
PartialIndexVectorcompleteIndexVectorVisitor – The visitor function for handling objects of the type
CompleteIndexVector
-
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 outputs whose indices are stored in this vector.
- Parameters:
statistics – A reference to an object of type
IStatisticsthat should be used to create the subsetweights – A reference to an object of type
EqualWeightVectorthat provides access to the weights of individual training examples
- Returns:
An unique pointer to an object of type
IStatisticsSubsetthat 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 outputs whose indices are stored in this vector.
- Parameters:
statistics – A reference to an object of type
IStatisticsthat should be used to create the subsetweights – A reference to an object of type
BitWeightVectorthat provides access to the weights of individual training examples
- Returns:
An unique pointer to an object of type
IStatisticsSubsetthat has been created
-
virtual std::unique_ptr<IStatisticsSubset> createStatisticsSubset(const IStatistics &statistics, const DenseWeightVector<uint16> &weights) const override¶
Creates and returns a new subset of the given statistics that only contains the outputs whose indices are stored in this vector.
- Parameters:
statistics – A reference to an object of type
IStatisticsthat should be used to create the subsetweights – A reference to an object of type
DenseWeightVector<uint16>that provides access to the weights of individual training examples
- Returns:
An unique pointer to an object of type
IStatisticsSubsetthat has been created
-
virtual std::unique_ptr<IStatisticsSubset> createStatisticsSubset(const IStatistics &statistics, const DenseWeightVector<float32> &weights) const override¶
Creates and returns a new subset of the given statistics that only contains the outputs whose indices are stored in this vector.
- Parameters:
statistics – A reference to an object of type
IStatisticsthat should be used to create the subsetweights – A reference to an object of type
DenseWeightVector<float32>that provides access to the weights of individual training examples
- Returns:
An unique pointer to an object of type
IStatisticsSubsetthat 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 outputs whose indices are stored in this vector.
- Parameters:
statistics – A reference to an object of type
IStatisticsthat should be used to create the subsetweights – 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
IStatisticsSubsetthat 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 outputs whose indices are stored in this vector.
- Parameters:
statistics – A reference to an object of type
IStatisticsthat should be used to create the subsetweights – 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
IStatisticsSubsetthat has been created
-
virtual std::unique_ptr<IStatisticsSubset> createStatisticsSubset(const IStatistics &statistics, const OutOfSampleWeightVector<DenseWeightVector<uint16>> &weights) const override¶
Creates and returns a new subset of the given statistics that only contains the outputs whose indices are stored in this vector.
- Parameters:
statistics – A reference to an object of type
IStatisticsthat should be used to create the subsetweights – A reference to an object of type
OutOfSampleWeightVector<DenseWeightVector<uint16>>that provides access to the weights of individual training examples
- Returns:
An unique pointer to an object of type
IStatisticsSubsetthat has been created
-
virtual std::unique_ptr<IStatisticsSubset> createStatisticsSubset(const IStatistics &statistics, const OutOfSampleWeightVector<DenseWeightVector<float32>> &weights) const override¶
Creates and returns a new subset of the given statistics that only contains the outputs whose indices are stored in this vector.
- Parameters:
statistics – A reference to an object of type
IStatisticsthat should be used to create the subsetweights – A reference to an object of type
OutOfSampleWeightVector<DenseWeightVector<float32>>that provides access to the weights of individual training examples
- Returns:
An unique pointer to an object of type
IStatisticsSubsetthat has been created
-
virtual void applyPrediction(uint32 statisticIndex) override¶
Updates a specific statistic.
This function must be called for each statistic that is covered by a new rule before learning the next rule.
- Parameters:
statisticIndex – The index of the statistic that should be updated
-
virtual void revertPrediction(uint32 statisticIndex) override¶
Reverts a specific statistic that has previously been updated via the function
applyPrediction.- Parameters:
statisticIndex – The index of the statistic that should be updated
Private Members
-
PartialIndexVector indexVector_¶
-
bool sorted_¶
-
std::unique_ptr<IStatisticsUpdate> statisticsUpdatePtr_¶