mlrl.common.testbed.runnables module

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

Provides base classes for programs that can be configured via command line arguments.

class mlrl.common.testbed.runnables.RuleLearnerRunnable(classifier_type: type[sklearn.base.ClassifierMixin] | None, classifier_config_type: type[RuleLearnerConfig] | None, classifier_parameters: set[Parameter] | None, regressor_type: type[sklearn.base.RegressorMixin] | None, regressor_config_type: type[RuleLearnerConfig] | None, regressor_parameters: set[Parameter] | None)

Bases: SkLearnRunnable

A base class for all programs that perform an experiment that involves training and evaluation of a rule learner.

class IncrementalPredictionExtension(*dependencies: Extension)

Bases: Extension

An extension that configures the functionality to obtain incremental predictions.

INCREMENTAL_EVALUATION = <mlrl.util.cli.BoolArgument object>
static get_predictor_factory(args: Namespace, prediction_type: PredictionType) PredictorFactory

Returns the SkLearnProblem.PredictorFactory that should be used for obtaining predictions of a specific type from a previously trained model according to the configuration.

Parameters:
  • args – The command line arguments specified by the user

  • prediction_type – The type of the predictions

Returns:

The SkLearnProblem.PredictorFactory that should be used

get_supported_modes() set[ExperimentMode]

See mlrl.testbed.extensions.extension.Extension.get_supported_modes()

class IncrementalPredictorFactory(prediction_type: PredictionType, min_size: int, max_size: int, step_size: int)

Bases: GlobalPredictorFactory

Allow to create instances of type Predictor that obtain incremental predictions from a model repeatedly.

create() Predictor

See from mlrl.testbed_sklearn.experiments.problem_domain.SkLearnProblem.PredictorFactory.create()

class RuleLearnerExtension(*dependencies: Extension)

Bases: Extension

An extension that configures the algorithmic parameters of a rule learner.

FEATURE_FORMAT = <mlrl.util.cli.EnumArgument object>
OUTPUT_FORMAT = <mlrl.util.cli.EnumArgument object>
PREDICTION_FORMAT = <mlrl.util.cli.EnumArgument object>
SPARSE_FEATURE_VALUE = <mlrl.util.cli.FloatArgument object>
static get_estimator(args: Namespace, estimator_type: type[sklearn.base.BaseEstimator], parameters: set[Parameter] | None) Any

Returns the scikit-learn estimator to be used in an experiment.

Parameters:
  • args – The command line arguments specified by the user

  • estimator_type – The type of the estimator

  • parameters – The algorithmic parameters of the estimator

static get_fit_kwargs(args: Namespace) dict[str, Any]

Returns the keyword arguments that should be passed to the estimators fit function.

Parameters:

args – The command line arguments specified by the user

Returns:

A dictionary that stores the keyword arguments

static get_predict_kwargs(args: Namespace) dict[str, Any]

Returns the keyword arguments that should be passed to the estimators predict function.

Parameters:

args – The command line arguments specified by the user

Returns:

A dictionary that stores the keyword arguments

get_supported_modes() set[ExperimentMode]

See mlrl.testbed.extensions.extension.Extension.get_supported_modes()

create_classifier(_: ExperimentMode, args: Namespace) SkLearnClassifierMixin | None

See mlrl.testbed.runnables.Runnable.create_classifier()

create_experiment_builder(experiment_mode: ExperimentMode, args: Namespace, command: Command, load_dataset: bool = True) Builder

See mlrl.testbed.experiments.recipe.Recipe.create_experiment_builder()

create_predictor_factory(args, prediction_type: PredictionType) PredictorFactory

See mlrl.testbed_sklearn.runnables.SkLearnRunnable.create_predictor_factory()

create_problem_domain(mode: ExperimentMode, args: Namespace)

See mlrl.testbed.experiments.recipe.Recipe.create_problem_domain()

create_regressor(_: ExperimentMode, args: Namespace) SkLearnRegressorMixin | None

See mlrl.testbed_sklearn.runnables.SkLearnRunnable.create_regressor()

get_algorithmic_arguments(mode: ExperimentMode, known_args: Namespace) set[Argument]

See mlrl.testbed.runnables.Runnable.get_algorithmic_arguments()

get_extensions() list[Extension]

See mlrl.testbed.runnables.Runnable.get_extensions()