mlens icon indicating copy to clipboard operation
mlens copied to clipboard

Error when using preprocessing per case in model selection

Open bastian-f opened this issue 1 year ago • 2 comments

Hello,

I followed this notebook to create an ensemble.

First I tune the base learners with a preprocessing pipeline:

preprocessing = {'sc': [StandardScaler()]}
# Fit the base learners
evl.fit(
    x_train, y_train,
    estimators=base_learners,
    param_dicts=param_dicts,
    preprocessing=preprocessing,
    n_iter=1
)

In the notebook, the model selection is done like this:

in_layer_proba = SuperLearner(model_selection=True).add(base_learners,
                                                        proba=True)
in_layer_class = SuperLearner(model_selection=True).add(base_learners,
                                                        proba=False)

This works fine, but I think the preprocessing part is missing here (the standard scaler), is it not? So I did the following:

in_layer_proba = SuperLearner(model_selection=True).add(
                estimators_per_case, preprocessing_cases, proba=True
)
in_layer_class = SuperLearner(model_selection=True).add(
        estimators_per_case, preprocessing_cases, proba=False
)
preprocess = {'proba': [('layer-1', in_layer_proba)],
                       'class': [('layer-1', in_layer_class)]}
evl.fit(
    x_train, y_train,
    meta_learners,
    param_dicts=param_dicts,
    preprocessing=preprocess,
    n_iter=1
)

And I get the following error. I am not sure if I am doing something wrong or if it is a bug?

bastian-f avatar Oct 11 '22 14:10 bastian-f