pymor.algorithms.ml.base_estimator

Module Contents

class pymor.algorithms.ml.base_estimator.BaseEstimator[source]

Bases: pymor.core.base.BasicObject

Base-class for scikit-learn-style estimators.

This class provides the get_params and set_params methods required to use the hyperparameter tuning methods of scikit-learn. In order to make use of the functionality, an inheriting regressor only needs to provide a tuple of init-parameters as strings (the _params class-attribute). If the regressor also contains another object with hyperparameters that might be adjusted, the _nested_object string referring to that attribute can be set. Special parameter handling can further be implemented by overriding the _get_extra_params and _set_extra_param methods, respectively. This class cannot be used directly but serves as a base class for other regressors.

Methods

get_params

Returns a dict of the init-parameters of the estimator, together with their values.

set_params

Set the parameters of the estimator and the nested object.

get_params(deep=True)[source]

Returns a dict of the init-parameters of the estimator, together with their values.

The argument deep=True is required to match the scikit-learn interface.

Parameters:

deep – If True, the parameters for this estimator and for the nested object (kernel, neural network, etc.) will be returned.

Returns:

A dictionary of parameters and respective values of the estimator.

set_params(**params)[source]

Set the parameters of the estimator and the nested object.

Supports nested parameter setting for the nested object using the value of self._nested_object as prefix.

Parameters:

params – Estimator parameters to set.

Returns:

An instance of the estimator with the new parameters.