File feature_subspace.hpp

class IFeatureSubspace
#include <feature_subspace.hpp>

Defines an interface for all classes that provide access to a subspace of the feature space that includes the training examples covered by a rule.

Public Functions

inline virtual ~IFeatureSubspace()
virtual std::unique_ptr<IFeatureSubspace> copy() const = 0

Creates and returns a copy of this object.

Returns:

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

virtual std::unique_ptr<ICallback> createCallback(uint32 featureIndex) = 0

Creates and returns a new instance of the type ICallback that allows to retrieve information that is required to search for the best refinement of a rule that covers all examples included in this subspace.

Parameters:

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

Returns:

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

virtual void filterSubspace(const Condition &condition) = 0

Filters the subspace such that it only includes those training examples that satisfy a specific condition.

Parameters:

condition – A reference to an object of type Condition

virtual void resetSubspace() = 0

Resets the subspace. This reverts the effects of all previous calls to the function filterSubspace.

virtual uint32 getNumCovered() const = 0

Returns the number of training examples with non-zero weights that are included in this subspace.

Returns:

The number of training examples included in this subspace

virtual const CoverageMask &getCoverageMask() const = 0

Returns an object of type CoverageMask that keeps track of the training examples that are included in this subspace.

Returns:

A reference to an object of type CoverageMask that keeps track of the training examples that are included in this subspace

virtual Quality evaluateOutOfSample(const SinglePartition &partition, const CoverageMask &coverageMask, const IPrediction &head) const = 0

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 instance sub-sample and are marked as covered according to a given CoverageMask.

For calculating the quality, only examples that belong to the training set and are not included in the current instance sub-sample, i.e., only examples with zero weights, are considered and assigned equally distributed weights.

Parameters:
  • partition – A reference to an object of type SinglePartition that provides access to the indices of the training examples that belong to the training set

  • 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 Quality evaluateOutOfSample(const BiPartition &partition, const CoverageMask &coverageMask, const IPrediction &head) const = 0

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 instance sub-sample and are marked as covered according to a given CoverageMask.

For calculating the quality, only examples that belong to the training set and are not included in the current instance sub-sample, i.e., only examples with zero weights, are considered and assigned equally distributed weights.

Parameters:
  • partition – A reference to an object of type BiPartition that provides access to the indices of the training examples that belong to the training set

  • 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 SinglePartition &partition, const CoverageMask &coverageMask, std::unique_ptr<IEvaluatedPrediction> &headPtr) const = 0

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

When calculating the updated prediction, the weights of the individual training examples are ignored and equally distributed weights are used instead.

Parameters:
  • partition – A reference to an object of type SinglePartition that provides access to the indices of the training examples that belong to the training set

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

  • headPtr – A reference to an unique pointer that stores an object of type IEvaluatedPrediction to be updated

virtual void recalculatePrediction(const BiPartition &partition, const CoverageMask &coverageMask, std::unique_ptr<IEvaluatedPrediction> &headPtr) const = 0

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

When calculating the updated prediction, the weights of the individual training examples are ignored and equally distributed weights are used instead.

Parameters:
  • partition – A reference to an object of type BiPartition that provides access to the indices of the training examples that belong to the training set

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

  • headPtr – A reference to an unique pointer that stores an object of type IEvaluatedPrediction to be updated

virtual void applyPrediction(IPrediction &prediction) = 0

Updates the statistics that correspond to the training examples included in this subspace based on the prediction of a rule.

Parameters:

prediction – A reference to an object of type IPrediction that stores the prediction of the rule

virtual void revertPrediction(IPrediction &prediction) = 0

Reverts the statistics that correspond to the training examples included in this subspace based on the predictions of a rule.

Parameters:

prediction – A reference to an object of type IPrediction that stores the prediction of the rule

class ICallback
#include <feature_subspace.hpp>

Defines an interface for callbacks that may be invoked in order to retrieve the information that is required to search for potential refinements of a rule. It consists of IWeightedStatistics, as well as an IFeatureVector that allows to determine the thresholds that may be used by potential conditions.

Public Functions

inline virtual ~ICallback()
virtual Result invoke() = 0

Invokes the callback and returns its result.

Returns:

An object of type Result that stores references to the statistics and the feature vector that may be used to search for potential refinements

struct Result
#include <feature_subspace.hpp>

The data that is provided via the callback’s get function.

Public Functions

inline Result(const IWeightedStatistics &statistics, const IFeatureVector &featureVector)
Parameters:
  • statistics – A reference to an object of type IWeightedStatistics that should be used to search for potential refinements

  • featureVector – A reference to an object of type IFeatureVector that should be used to search for potential refinements

inline Result(const Result &other)
Parameters:

other – A reference to an object of type Result that should be copied

Public Members

const IWeightedStatistics &statistics

A reference to an object of type IWeightedStatistics that should be used to search for potential refinements.

const IFeatureVector &featureVector

A reference to an object of type IFeatureVector that should be used to search for potential refinements.