File learner_classification_common.hpp

class AbstractClassificationRuleLearner : public virtual IClassificationRuleLearner
#include <learner_classification_common.hpp>

An abstract base class for all rule learners that can be used in classification problems.

Public Functions

inline explicit AbstractClassificationRuleLearner(const RuleLearnerConfigurator &configurator)
Parameters:

configurator – A reference to an object of type RuleLearnerConfigurator that allows to configure the individual modules to be used by the rule learner

inline virtual ~AbstractClassificationRuleLearner() override
inline virtual std::unique_ptr<ITrainingResult> fit(const IExampleWeights &exampleWeights, const IFeatureInfo &featureInfo, const IColumnWiseFeatureMatrix &featureMatrix, const IRowWiseLabelMatrix &labelMatrix) const override

Applies the rule learner to given training examples and corresponding ground truth labels.

Parameters:
  • exampleWeights – A reference to an object of type IExampleWeights that provides access to the weights of the training examples

  • featureInfo – A reference to an object of type IFeatureInfo that provides information about the types of individual features

  • featureMatrix – A reference to an object of type IColumnWiseFeatureMatrix that provides column-wise access to the feature values of the training examples

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

Returns:

An unique pointer to an object of type ITrainingResult that provides access to the results of fitting the rule learner to the training data

inline virtual bool canPredictScores(const IRowWiseFeatureMatrix &featureMatrix, uint32 numLabels) const override

Returns whether the rule learner is able to predict scores or not.

Parameters:
  • featureMatrix – A reference to an object of type IRowWiseFeatureMatrix that provides row-wise access to the feature values of the query examples

  • numLabels – The number of labels to predict for

Returns:

True, if the rule learner is able to predict scores, false otherwise

inline virtual std::unique_ptr<IScorePredictor> createScorePredictor(const IRowWiseFeatureMatrix &featureMatrix, const IRuleModel &ruleModel, const IOutputSpaceInfo &outputSpaceInfo, uint32 numOutputs) const override

Creates and returns a predictor that may be used to predict scores for given query examples. If the prediction of scores is not supported by the rule learner, a std::runtime_error is thrown.

Throws:

std::runtime_exception – The exception that is thrown if the prediction of scores is not supported by the rule learner

Parameters:
  • featureMatrix – A reference to an object of type IRowWiseFeatureMatrix that provides row-wise access to the feature values of the query examples

  • ruleModel – A reference to an object of type IRuleModel that should be used to obtain predictions

  • outputSpaceInfo – A reference to an object of type IOutputSpaceInfo that provides information about the output space that may be used as a basis for obtaining predictions

  • numLabels – The number of labels to predict for

Returns:

An unique pointer to an object of type IScorePredictor that may be used to predict scores for the given query examples

inline virtual bool canPredictProbabilities(const IRowWiseFeatureMatrix &featureMatrix, uint32 numLabels) const override

Returns whether the rule learner is able to predict probabilities or not.

Parameters:
  • featureMatrix – A reference to an object of type IRowWiseFeatureMatrix that provides row-wise access to the feature values of the query examples

  • numLabels – The number of labels to predict for

Returns:

True, if the rule learner is able to predict probabilities, false otherwise

inline virtual std::unique_ptr<IProbabilityPredictor> createProbabilityPredictor(const IRowWiseFeatureMatrix &featureMatrix, const IRuleModel &ruleModel, const IOutputSpaceInfo &outputSpaceInfo, const IMarginalProbabilityCalibrationModel &marginalProbabilityCalibrationModel, const IJointProbabilityCalibrationModel &jointProbabilityCalibrationModel, uint32 numLabels) const override

Creates and returns a predictor that may be used to predict probability estimates for given query examples. If the prediction of probability estimates is not supported by the rule learner, a std::runtime_error is thrown.

Throws:

std::runtime_exception – The exception that is thrown if the prediction of probability estimates is not supported by the rule learner

Parameters:
  • featureMatrix – A reference to an object of type IRowWiseFeatureMatrix that provides row-wise access to the feature values of the query examples

  • ruleModel – A reference to an object of type IRuleModel that should be used to obtain predictions

  • outputSpaceInfo – A reference to an object of type IOutputSpaceInfo that provides information about the output space that may be used as a basis for obtaining predictions

  • marginalProbabilityCalibrationModel – A reference to an object of type IMarginalProbabilityCalibrationModel that may be used for the calibration of marginal probabilities

  • jointProbabilityCalibrationModel – A reference to an object of type IJointProbabilityCalibrationModel that may be used for the calibration of joint probabilities

  • numLabels – The number of labels to predict for

Returns:

An unique pointer to an object of type IProbabilityPredictor that may be used to predict probability estimates for the given query examples

inline virtual bool canPredictBinary(const IRowWiseFeatureMatrix &featureMatrix, uint32 numLabels) const override

Returns whether the rule learner is able to predict binary labels or not.

Parameters:
  • featureMatrix – A reference to an object of type IRowWiseFeatureMatrix that provides row-wise access to the feature values of the query examples

  • numLabels – The number of labels to predict for

Returns:

True, if the rule learner is able to predict binary labels, false otherwise

inline virtual std::unique_ptr<IBinaryPredictor> createBinaryPredictor(const IRowWiseFeatureMatrix &featureMatrix, const IRuleModel &ruleModel, const IOutputSpaceInfo &outputSpaceInfo, const IMarginalProbabilityCalibrationModel &marginalProbabilityCalibrationModel, const IJointProbabilityCalibrationModel &jointProbabilityCalibrationModel, uint32 numLabels) const override

Creates and returns a predictor that may be used to predict binary labels for given query examples. If the prediction of binary labels is not supported by the rule learner, a std::runtime_error is thrown.

Throws:

std::runtime_exception – The exception that is thrown if the prediction of binary labels is not supported by the rule learner

Parameters:
  • featureMatrix – A reference to an object of type IRowWiseFeatureMatrix that provides row-wise access to the feature values of the query examples

  • ruleModel – A reference to an object of type IRuleModel that should be used to obtain predictions

  • outputSpaceInfo – A reference to an object of type IOutputSpaceInfo that provides information about the output space that may be used as a basis for obtaining predictions

  • marginalProbabilityCalibrationModel – A reference to an object of type IMarginalProbabilityCalibrationModel that may be used for the calibration of marginal probabilities

  • jointProbabilityCalibrationModel – A reference to an object of type IJointProbabilityCalibrationModel that may be used for the calibration of joint probabilities

  • numLabels – The number of labels to predict for

Returns:

An unique pointer to an object of type IBinaryPredictor that may be used to predict binary labels for the given query examples

inline virtual std::unique_ptr<ISparseBinaryPredictor> createSparseBinaryPredictor(const IRowWiseFeatureMatrix &featureMatrix, const IRuleModel &ruleModel, const IOutputSpaceInfo &outputSpaceInfo, const IMarginalProbabilityCalibrationModel &marginalProbabilityCalibrationModel, const IJointProbabilityCalibrationModel &jointProbabilityCalibrationModel, uint32 numLabels) const override

Creates and returns a predictor that may be used to predict sparse binary labels for given query examples. If the prediction of sparse binary labels is not supported by the rule learner, a std::runtime_error is thrown.

Throws:

std::runtime_exception – The exception that is thrown if the prediction of sparse binary labels is not supported by the rule learner

Parameters:
  • featureMatrix – A reference to an object of type IRowWiseFeatureMatrix that provides row-wise access to the feature values of the query examples

  • ruleModel – A reference to an object of type IRuleModel that should be used to obtain predictions

  • outputSpaceInfo – A reference to an object of type IOutputSpaceInfo that provides information about the output space that may be used as a basis for obtaining predictions

  • marginalProbabilityCalibrationModel – A reference to an object of type IMarginalProbabilityCalibrationModel that may be used for the calibration of marginal probabilities

  • jointProbabilityCalibrationModel – A reference to an object of type IJointProbabilityCalibrationModel that may be used for the calibration of joint probabilities

  • numLabels – The number of labels to predict for

Returns:

An unique pointer to an object of type ISparseBinaryPredictor that may be used to predict sparse binary labels for the given query examples

Private Members

const RuleLearnerConfigurator &configurator_