File partition_bi.hpp

class BiPartition : public VectorDecorator<AllocatedVector<uint32>>, public IPartition
#include <partition_bi.hpp>

An implementation of the class IPartition that provides random access to the indices of elements that are included two, mutually exclusive, sets.

Public Types

typedef View<uint32>::iterator iterator

An iterator that provides access to the indices that are contained by the first or second set and allows to modify them.

typedef View<uint32>::const_iterator const_iterator

An iterator that provides read-only access to the indices that are contained in the first or second set.

Public Functions

BiPartition(uint32 numFirst, uint32 numSecond)
Parameters:
  • numFirst – The number of elements that are contained by the first set

  • numSecond – The number of elements that are contained by the second set

iterator first_begin()

Returns an iterator to the beginning of the elements that are contained by the first set.

Returns:

An iterator to the beginning of the first set

iterator first_end()

Returns an iterator to the end of the elements that are contained by the first set.

Returns:

An iterator to the end of the first set

const_iterator first_cbegin() const

Returns a const_iterator to the beginning of the elements that are contained by the first set.

Returns:

A const_iterator to the beginning of the first set

const_iterator first_cend() const

Returns a const_iterator to the end of the elements that are contained by the first set.

Returns:

A const_iterator to the end of the first set

iterator second_begin()

Returns an iterator to the beginning of the elements that are contained by the second set.

Returns:

An iterator to the beginning of the second set

iterator second_end()

Returns an iterator to the beginning of the elements that are contained by the second set.

Returns:

An iterator to the beginning of the second set

const_iterator second_cbegin() const

Returns a const_iterator to the beginning of the elements that are contained by the second set.

Returns:

A const_iterator to the beginning of the second set

const_iterator second_cend() const

Returns a const_iterator to the end of the elements that are contained by the second set.

Returns:

A const_iterator to the end of the second set

uint32 getNumFirst() const

Returns the number of elements that are contained by the first set.

Returns:

The number of elements that are contained by the first set

uint32 getNumSecond() const

Returns the number of elements that are contained by the second set.

Returns:

The number of elements that are contained by the second set

void sortFirst()

Sorts the elements that are contained by the first set in increasing order.

void sortSecond()

Sorts the elements that are contained by the second set in increasing order.

virtual std::unique_ptr<IStoppingCriterion> createStoppingCriterion(const IStoppingCriterionFactory &factory) override

Creates and returns a new instance of the class IStoppingCriterion, based on the type of this partition.

Parameters:

factory – A reference to an object of type IStoppingCriterionFactory that should be used to create the instance

Returns:

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

virtual std::unique_ptr<IInstanceSampling> createInstanceSampling(const IInstanceSamplingFactory &factory, const IRowWiseLabelMatrix &labelMatrix, IStatistics &statistics) override

Creates and returns a new instance of the class IInstanceSampling, based on the type of this partition.

Parameters:
  • factory – A reference to an object of type IInstanceSamplingFactory that should be used to create the instance

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

  • statistics – A reference to an object of type IStatistics that provides access to the statistics which serve as a basis for learning rules

Returns:

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

virtual Quality evaluateOutOfSample(const IFeatureSubspace &featureSubspace, const CoverageMask &coverageMask, const IPrediction &head) override

Calculates and returns a numerical score that assesses the quality of a rule’s prediction for all examples that do not belong to the current sample and are marked as covered according to a given object of type CoverageMask.

Parameters:
  • featureSubspace – A reference to an object of type IFeatureSubspace that should be used to evaluate the prediction

  • coverageMask – A reference to an object of type CoverageMask that keeps track of the examples that are covered by the rule

  • head – A reference to an object of type IPrediction that stores the scores that are predicted by the rule

Returns:

An object of type Quality that stores the calculated quality

virtual void recalculatePrediction(const IFeatureSubspace &featureSubspace, const CoverageMask &coverageMask, IPrediction &head) override

Recalculates and updates a rule’s prediction based on all examples in the training set that are marked as covered according to a given object of type CoverageMask.

Parameters:
  • featureSubspace – A reference to an object of type IFeatureSubspace that should be used to recalculate the prediction

  • coverageMask – A reference to an object of type CoverageMask that keeps track of the examples that are covered by the rule

  • head – A reference to an object of type IPrediction to be updated

virtual std::unique_ptr<IMarginalProbabilityCalibrationModel> fitMarginalProbabilityCalibrationModel(const IMarginalProbabilityCalibrator &probabilityCalibrator, const IRowWiseLabelMatrix &labelMatrix, const IStatistics &statistics) override

Fits and returns a model for the calibration of marginal probabilities, based on the type of this partition.

Parameters:
  • probabilityCalibrator – A reference to an object of type IMarginalProbabilityCalibrator that should be used to fit the calibration model

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

  • statistics – A reference to an object of type IStatistics that provides access to statistics about the labels of the training examples

Returns:

An unique pointer to an object of type IMarginalProbabilityCalibrationModel that has been fit

virtual std::unique_ptr<IJointProbabilityCalibrationModel> fitJointProbabilityCalibrationModel(const IJointProbabilityCalibrator &probabilityCalibrator, const IRowWiseLabelMatrix &labelMatrix, const IStatistics &statistics) override

Fits and returns a model for the calibration of joint probabilities, based on the type of this partition.

Parameters:
  • probabilityCalibrator – A reference to an object of type IJointProbabilityCalibrator that should be used to fit the calibration model

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

  • statistics – A reference to an object of type IStatistics that provides access to statistics about the labels of the training examples

Returns:

An unique pointer to an object of type IJointProbabilityCalibrationModel that has been fit

Private Members

const uint32 numFirst_
bool firstSorted_
bool secondSorted_