mlrl.common.cython.learner_regression module

@author: Michael Rapp (michael.rapp.ml@gmail.com)

class mlrl.common.cython.learner_regression.RegressionRuleLearner

Bases: object

A rule learner that can be applied to regression problems.

can_predict_scores(feature_matrix, num_labels) bool

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

Parameters:
  • feature_matrix – A RowWiseFeatureMatrix that provides row-wise access to the feature values of the query examples

  • num_labels – The number of labels to predict for

Returns:

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

create_score_predictor(feature_matrix, rule_model, output_space_info, num_labels) ScorePredictor

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 RuntimeError is thrown.

Parameters:
  • feature_matrix – A RowWiseFeatureMatrix that provides row-wise access to the feature values of the query examples

  • rule_model – The RuleModel that should be used to obtain predictions

  • output_space_info – The OutputSpaceInfo that provides information about the output space that may be used as a basis for obtaining predictions

  • num_labels – The number of labels to predict for

Returns:

A ScorePredictor that may be used to predict scores for the given query examples

fit(example_weights, feature_info, feature_matrix, regression_matrix) TrainingResult

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

Parameters:
  • example_weightsExampleWeights that provide access to the weights of individual training examples

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

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

  • regression_matrix – A reference to an object of type IRowWiseRegressionMatrix that provides row-wise access to the ground truth regression scores 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