mlrl.testbed_sklearn.runnables module

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

Provides classes for running experiments using the scikit-learn framework.

class mlrl.testbed_sklearn.runnables.SkLearnRunnable

Bases: Runnable, ABC

An abstract base class for all programs that run an experiment using the scikit-learn framework.

class BatchConfigFile(file_path: str)

Bases: ConfigFile

A YAML configuration file that configures a batch of experiments using the scikit-learn framework to be run.

property dataset_args: List[ArgumentList]

See from mlrl.testbed.modes.BatchMode.ConfigFile.dataset_args()

class GlobalPredictorFactory(prediction_type: PredictionType)

Bases: PredictorFactory

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

create() Predictor

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

class ProblemDomainExtension

Bases: Extension

An extension that configures the problem domain.

PROBLEM_TYPE = <mlrl.util.cli.SetArgument object>
static get_problem_domain(args: Namespace, runnable: SkLearnRunnable, fit_kwargs: Dict[str, Any] | None = None, predict_kwargs: Dict[str, Any] | None = None) ProblemDomain

Returns the problem domain that should be tackled by an experiment.

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

  • runnable – The SkLearnRunnable that is used to run the experiment

  • fit_kwargs – Optional keyword arguments to be passed to the estimator’s predict function

  • predict_kwargs – Optional keyword arguments to be passed to the estimator’s fit function

Returns:

The problem domain that should be tackled by the experiment

create_batch_config_file_factory() Callable[[str], ConfigFile]

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

abstractmethod create_classifier(args: Namespace) sklearn.base.ClassifierMixin | None

Must be implemented by subclasses in order to create a machine learning algorithm that can be applied to classification problems.

Parameters:

args – The command line arguments

Returns:

The learner that has been created or None, if regression problems are not supported

create_dataset_splitter(args: Namespace) DatasetSplitter

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

create_experiment_builder(args: Namespace) Builder

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

create_predictor_factory(args: Namespace, prediction_type: PredictionType) PredictorFactory

May be overridden by subclasses in order to create the SkLearnProblem.PredictorFactory that should be used for obtaining predictions from a previously trained model.

Parameters:
  • args – The command line arguments

  • prediction_type – The type of the predictions to be obtained

Returns:

The SkLearnProblem.PredictorFactory that has been created

create_problem_domain(args: Namespace) ProblemDomain

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

abstractmethod create_regressor(args: Namespace) sklearn.base.RegressorMixin | None

Must be implemented by subclasses in order to create a machine learning algorithm that can be applied to regression problems.

Parameters:

args – The command line arguments

Returns:

The learner that has been created or None, if regression problems are not supported

get_extensions() Set[Extension]

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