neuraxle.steps.sklearn

Module-level documentation for neuraxle.steps.sklearn. Here is an inheritance diagram, including dependencies to other base modules of Neuraxle:

Inheritance diagram of neuraxle.steps.sklearn

Pipeline Steps Based on Scikit-Learn

Those steps works with scikit-learn (sklearn) transformers and estimators.

Classes

RidgeModelStacking(brothers)

SKLearnWrapper(wrapped_sklearn_predictor, …)

Examples using neuraxle.steps.sklearn.RidgeModelStacking

Examples using neuraxle.steps.sklearn.SKLearnWrapper


class neuraxle.steps.sklearn.SKLearnWrapper(wrapped_sklearn_predictor, hyperparams_space: neuraxle.hyperparams.space.HyperparameterSpace = None, return_all_sklearn_default_params_on_get: bool = False, use_partial_fit: bool = False, use_predict_proba: bool = False, partial_fit_kwargs: dict = None)[source]

Bases: neuraxle.base.BaseStep

__init__(wrapped_sklearn_predictor, hyperparams_space: neuraxle.hyperparams.space.HyperparameterSpace = None, return_all_sklearn_default_params_on_get: bool = False, use_partial_fit: bool = False, use_predict_proba: bool = False, partial_fit_kwargs: dict = None)[source]

Initialize self. See help(type(self)) for accurate signature.

setup(context: neuraxle.base.ExecutionContext = None) → neuraxle.steps.sklearn.SKLearnWrapper[source]

Initialize the step before it runs. Only from here and not before that heavy things should be created (e.g.: things inside GPU), and NOT in the constructor.

Warning

The setup method is called once for each step when handle_fit, handle_fit_transform or handle_transform is called. The setup method is executed only if is self.is_initialized is False A setup function should set the self.is_initialized to True when called.

Parameters

context (ExecutionContext) – execution context

Returns

self

_delete_base_estimator_from_dict(params)[source]

Sklearn BaseEnsemble models contain other models as parameter; those can’t be json encoded. We retrieve the parameters of theses sub-models on a .get_params(deep=True) call, we simply need to delete them from the parameter dictionary to avoid errors when saving/loading hyperparameters.

fit_transform(data_inputs, expected_outputs=None) -> ('BaseStep', typing.Any)[source]

Fit, and transform step with the given data inputs, and expected outputs.

Parameters
  • data_inputs – data inputs

  • expected_outputs – expected outputs to fit on

Returns

(fitted self, tranformed data inputs)

_sklearn_fit_transform_with_expected_outputs(data_inputs, expected_outputs)[source]
_sklearn_fit_transform_without_expected_outputs(data_inputs)[source]
fit(data_inputs, expected_outputs=None) → neuraxle.steps.sklearn.SKLearnWrapper[source]

Fit data inputs on the given expected outputs.

Parameters
  • data_inputs – data inputs

  • expected_outputs – expected outputs to fit on.

Returns

self

_sklearn_fit_with_expected_outputs(data_inputs, expected_outputs)[source]
_sklearn_fit_without_expected_outputs(data_inputs)[source]
transform(data_inputs)[source]

Transform given data inputs.

Parameters

data_inputs – data inputs

Returns

transformed data inputs

_set_hyperparams(hyperparams: neuraxle.hyperparams.space.HyperparameterSamples) → neuraxle.base.BaseStep[source]

Set hyperparams for base step, and the wrapped sklearn_predictor.

Return type

BaseStep

Parameters

hyperparams (HyperparameterSamples) –

Returns

self

_update_hyperparams(hyperparams: neuraxle.hyperparams.space.HyperparameterSamples) → neuraxle.base.BaseStep[source]

Update hyperparams for base step, and the wrapped sklearn_predictor.

Return type

BaseStep

Parameters

hyperparams (HyperparameterSamples) –

Returns

self

_get_hyperparams()[source]
get_wrapped_sklearn_predictor()[source]
_repr(level=0, verbose=False) → str[source]
_abc_impl = <_abc_data object>
class neuraxle.steps.sklearn.RidgeModelStacking(brothers)[source]

Bases: neuraxle.union.ModelStacking

__init__(brothers)[source]

Perform model stacking. The steps will be merged with a FeatureUnion, and the judge will recombine the predictions. :param steps_as_tuple: the NamedTupleList of steps to process in parallel and to join. :param judge: a BaseStep that will learn to judge the best answer and who to trust out of every parallel steps. :param kwargs: Other arguments to send to FeatureUnion.

_abc_impl = <_abc_data object>