Stacking Classification

This example uses the iris dataset and performs a complex stacking classification. We will use two different classifiers, one applied to petal features and one applied to sepal features. A final logistic regression classifier will be applied on the predictions of the two classifiers.

# Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
# License: AGPL

from seaborn import load_dataset
from julearn import run_cross_validation
from julearn.pipeline import PipelineCreator
from julearn.utils import configure_logging

Set the logging level to info to see extra information.

configure_logging(level="INFO")
2026-10-27 10:54:58,437 - julearn - INFO - ===== Lib Versions =====
2026-10-27 10:54:58,438 - julearn - INFO - numpy: 2.5.4
2026-10-27 10:54:58,438 - julearn - INFO - scipy: 1.18.1
2026-10-27 10:54:58,438 - julearn - INFO - sklearn: 1.9.1
2026-10-27 10:54:58,438 - julearn - INFO - pandas: 3.1.0
2026-10-27 10:54:58,438 - julearn - INFO - julearn: 0.3.6.dev108
2026-10-27 10:54:58,438 - julearn - INFO - ========================
df_iris = load_dataset("iris")

The dataset has three kind of species. We will keep two to perform a binary classification.

df_iris = df_iris[df_iris["species"].isin(["versicolor", "virginica"])]

As features, we will use the sepal length, width and petal length. We will try to predict the species.

X = ["sepal_length", "sepal_width", "petal_length", "petal_width"]
y = "species"

# Define our feature types
X_types = {
    "sepal": ["sepal_length", "sepal_width"],
    "petal": ["petal_length", "petal_width"],
}

# Create the pipeline for the sepal features, by default will apply to "sepal"
model_sepal = PipelineCreator(problem_type="classification", apply_to="sepal")
model_sepal.add("filter_columns", apply_to="*", keep="sepal")
model_sepal.add("zscore")
model_sepal.add("svm")

# Create the pipeline for the petal features, by default will apply to "petal"
model_petal = PipelineCreator(problem_type="classification", apply_to="petal")
model_petal.add("filter_columns", apply_to="*", keep="petal")
model_petal.add("zscore")
model_petal.add("rf")

# Create the stacking model
model = PipelineCreator(problem_type="classification")
model.add(
    "stacking",
    estimators=[[("model_sepal", model_sepal), ("model_petal", model_petal)]],
    apply_to="*",
)

scores = run_cross_validation(
    X=X, y=y, X_types=X_types, data=df_iris, model=model
)

print(scores["test_score"])
2026-10-27 10:54:58,441 - julearn - INFO - Adding step filter_columns that applies to ColumnTypes<types={'*'}; pattern=.*>
2026-10-27 10:54:58,442 - julearn - INFO - Setting hyperparameter keep = sepal
2026-10-27 10:54:58,442 - julearn - INFO - Step added
2026-10-27 10:54:58,442 - julearn - INFO - Adding step zscore that applies to ColumnTypes<types={'sepal'}; pattern=(?:__:type:__sepal)>
2026-10-27 10:54:58,442 - julearn - INFO - Step added
2026-10-27 10:54:58,443 - julearn - INFO - Adding step svm that applies to ColumnTypes<types={'sepal'}; pattern=(?:__:type:__sepal)>
2026-10-27 10:54:58,443 - julearn - INFO - Step added
2026-10-27 10:54:58,443 - julearn - INFO - Adding step filter_columns that applies to ColumnTypes<types={'*'}; pattern=.*>
2026-10-27 10:54:58,443 - julearn - INFO - Setting hyperparameter keep = petal
2026-10-27 10:54:58,443 - julearn - INFO - Step added
2026-10-27 10:54:58,443 - julearn - INFO - Adding step zscore that applies to ColumnTypes<types={'petal'}; pattern=(?:__:type:__petal)>
2026-10-27 10:54:58,444 - julearn - INFO - Step added
2026-10-27 10:54:58,444 - julearn - INFO - Adding step rf that applies to ColumnTypes<types={'petal'}; pattern=(?:__:type:__petal)>
2026-10-27 10:54:58,444 - julearn - INFO - Step added
2026-10-27 10:54:58,444 - julearn - INFO - Adding step stacking that applies to ColumnTypes<types={'*'}; pattern=.*>
2026-10-27 10:54:58,444 - julearn - INFO - Setting hyperparameter estimators = [('model_sepal', <julearn.pipeline.pipeline_creator.PipelineCreator object at 0x7037680d3f50>), ('model_petal', <julearn.pipeline.pipeline_creator.PipelineCreator object at 0x7037481f2bd0>)]
2026-10-27 10:54:58,444 - julearn - INFO - Step added
2026-10-27 10:54:58,445 - julearn - INFO - ==== Input Data ====
2026-10-27 10:54:58,445 - julearn - INFO - Using dataframe as input
2026-10-27 10:54:58,445 - julearn - INFO -      Features: ['sepal_length', 'sepal_width', 'petal_length', 'petal_width']
2026-10-27 10:54:58,445 - julearn - INFO -      Target: species
2026-10-27 10:54:58,445 - julearn - INFO -      Expanded features: ['sepal_length', 'sepal_width', 'petal_length', 'petal_width']
2026-10-27 10:54:58,445 - julearn - INFO -      X_types:{'sepal': ['sepal_length', 'sepal_width'], 'petal': ['petal_length', 'petal_width']}
2026-10-27 10:54:58,447 - julearn - INFO - ====================
2026-10-27 10:54:58,447 - julearn - INFO -
2026-10-27 10:54:58,447 - julearn - INFO - = Model Parameters =
2026-10-27 10:54:58,447 - julearn - INFO - ====================
2026-10-27 10:54:58,448 - julearn - INFO -
2026-10-27 10:54:58,448 - julearn - INFO - = Model Parameters =
2026-10-27 10:54:58,448 - julearn - INFO - ====================
2026-10-27 10:54:58,448 - julearn - INFO -
2026-10-27 10:54:58,449 - julearn - INFO - = Model Parameters =
2026-10-27 10:54:58,449 - julearn - INFO - ====================
2026-10-27 10:54:58,450 - julearn - INFO -
2026-10-27 10:54:58,450 - julearn - INFO - = Data Information =
2026-10-27 10:54:58,450 - julearn - INFO -      Problem type: classification
2026-10-27 10:54:58,450 - julearn - INFO -      Number of samples: 100
2026-10-27 10:54:58,450 - julearn - INFO -      Number of features: 4
2026-10-27 10:54:58,450 - julearn - INFO - ====================
2026-10-27 10:54:58,450 - julearn - INFO -
2026-10-27 10:54:58,451 - julearn - INFO -      Number of classes: 2
2026-10-27 10:54:58,451 - julearn - INFO -      Target type: str
2026-10-27 10:54:58,451 - julearn - INFO -      Class distributions: species
versicolor    50
virginica     50
Name: count, dtype: int64
2026-10-27 10:54:58,452 - julearn - INFO - Using outer CV scheme KFold(n_splits=5, random_state=None, shuffle=False)
2026-10-27 10:54:58,453 - julearn - WARNING - The kind of values in y (str) is not suitable for a classification. Values should be numeric.
/tmp/tmponjkxoub/julearn/prepare.py:422: RuntimeWarning: The kind of values in y (str) is not suitable for a classification. Values should be numeric.
  warn_with_log(
2026-10-27 10:54:58,453 - julearn - INFO - Binary classification problem detected.
/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/model_selection/_validation.py:960: UserWarning: Scoring failed. The score on this train-test partition for these parameters will be set to nan. Details:
Traceback (most recent call last):
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/model_selection/_validation.py", line 949, in _score
    scores = scorer(estimator, X_test, y_test, **score_params)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/metrics/_scorer.py", line 537, in __call__
    return estimator.score(*args, **kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/julearn/pipeline/ju_pipeline.py", line 72, in score
    return super().score(X, y, sample_weight=sample_weight, **params)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/pipeline.py", line 1202, in score
    return self.steps[-1][1].score(Xt, y, **score_params)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/base.py", line 628, in score
    return accuracy_score(y, self.predict(X), sample_weight=sample_weight)
                             ~~~~~~~~~~~~^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 750, in predict
    y_pred = super().predict(X, **routed_params.final_estimator_["predict"])
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 373, in predict
    return self.final_estimator_.predict(self.transform(X), **predict_params)
                                         ~~~~~~~~~~~~~~^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 340, in wrapped
    return _wrap_data_with_container(method, data_to_wrap, X, self)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 315, in _wrap_data_with_container
    return adapter.create_container(
           ~~~~~~~~~~~~~~~~~~~~~~~~^
        data_to_wrap,
        ^^^^^^^^^^^^^
        original_input,
        ^^^^^^^^^^^^^^^
        columns=estimator.get_feature_names_out,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 122, in create_container
    columns = get_columns(columns)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 30, in get_columns
    return columns()
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 325, in get_feature_names_out
    check_is_fitted(self, "n_features_in_")
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/validation.py", line 1721, in check_is_fitted
    raise NotFittedError(msg % {"name": type(estimator).__name__})
sklearn.exceptions.NotFittedError: This StackingClassifier instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.

  warnings.warn(
/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/model_selection/_validation.py:960: UserWarning: Scoring failed. The score on this train-test partition for these parameters will be set to nan. Details:
Traceback (most recent call last):
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/model_selection/_validation.py", line 949, in _score
    scores = scorer(estimator, X_test, y_test, **score_params)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/metrics/_scorer.py", line 537, in __call__
    return estimator.score(*args, **kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/julearn/pipeline/ju_pipeline.py", line 72, in score
    return super().score(X, y, sample_weight=sample_weight, **params)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/pipeline.py", line 1202, in score
    return self.steps[-1][1].score(Xt, y, **score_params)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/base.py", line 628, in score
    return accuracy_score(y, self.predict(X), sample_weight=sample_weight)
                             ~~~~~~~~~~~~^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 750, in predict
    y_pred = super().predict(X, **routed_params.final_estimator_["predict"])
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 373, in predict
    return self.final_estimator_.predict(self.transform(X), **predict_params)
                                         ~~~~~~~~~~~~~~^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 340, in wrapped
    return _wrap_data_with_container(method, data_to_wrap, X, self)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 315, in _wrap_data_with_container
    return adapter.create_container(
           ~~~~~~~~~~~~~~~~~~~~~~~~^
        data_to_wrap,
        ^^^^^^^^^^^^^
        original_input,
        ^^^^^^^^^^^^^^^
        columns=estimator.get_feature_names_out,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 122, in create_container
    columns = get_columns(columns)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 30, in get_columns
    return columns()
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 325, in get_feature_names_out
    check_is_fitted(self, "n_features_in_")
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/validation.py", line 1721, in check_is_fitted
    raise NotFittedError(msg % {"name": type(estimator).__name__})
sklearn.exceptions.NotFittedError: This StackingClassifier instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.

  warnings.warn(
/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/model_selection/_validation.py:960: UserWarning: Scoring failed. The score on this train-test partition for these parameters will be set to nan. Details:
Traceback (most recent call last):
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/model_selection/_validation.py", line 949, in _score
    scores = scorer(estimator, X_test, y_test, **score_params)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/metrics/_scorer.py", line 537, in __call__
    return estimator.score(*args, **kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/julearn/pipeline/ju_pipeline.py", line 72, in score
    return super().score(X, y, sample_weight=sample_weight, **params)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/pipeline.py", line 1202, in score
    return self.steps[-1][1].score(Xt, y, **score_params)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/base.py", line 628, in score
    return accuracy_score(y, self.predict(X), sample_weight=sample_weight)
                             ~~~~~~~~~~~~^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 750, in predict
    y_pred = super().predict(X, **routed_params.final_estimator_["predict"])
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 373, in predict
    return self.final_estimator_.predict(self.transform(X), **predict_params)
                                         ~~~~~~~~~~~~~~^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 340, in wrapped
    return _wrap_data_with_container(method, data_to_wrap, X, self)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 315, in _wrap_data_with_container
    return adapter.create_container(
           ~~~~~~~~~~~~~~~~~~~~~~~~^
        data_to_wrap,
        ^^^^^^^^^^^^^
        original_input,
        ^^^^^^^^^^^^^^^
        columns=estimator.get_feature_names_out,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 122, in create_container
    columns = get_columns(columns)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 30, in get_columns
    return columns()
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 325, in get_feature_names_out
    check_is_fitted(self, "n_features_in_")
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/validation.py", line 1721, in check_is_fitted
    raise NotFittedError(msg % {"name": type(estimator).__name__})
sklearn.exceptions.NotFittedError: This StackingClassifier instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.

  warnings.warn(
/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/model_selection/_validation.py:960: UserWarning: Scoring failed. The score on this train-test partition for these parameters will be set to nan. Details:
Traceback (most recent call last):
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/model_selection/_validation.py", line 949, in _score
    scores = scorer(estimator, X_test, y_test, **score_params)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/metrics/_scorer.py", line 537, in __call__
    return estimator.score(*args, **kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/julearn/pipeline/ju_pipeline.py", line 72, in score
    return super().score(X, y, sample_weight=sample_weight, **params)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/pipeline.py", line 1202, in score
    return self.steps[-1][1].score(Xt, y, **score_params)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/base.py", line 628, in score
    return accuracy_score(y, self.predict(X), sample_weight=sample_weight)
                             ~~~~~~~~~~~~^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 750, in predict
    y_pred = super().predict(X, **routed_params.final_estimator_["predict"])
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 373, in predict
    return self.final_estimator_.predict(self.transform(X), **predict_params)
                                         ~~~~~~~~~~~~~~^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 340, in wrapped
    return _wrap_data_with_container(method, data_to_wrap, X, self)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 315, in _wrap_data_with_container
    return adapter.create_container(
           ~~~~~~~~~~~~~~~~~~~~~~~~^
        data_to_wrap,
        ^^^^^^^^^^^^^
        original_input,
        ^^^^^^^^^^^^^^^
        columns=estimator.get_feature_names_out,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 122, in create_container
    columns = get_columns(columns)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 30, in get_columns
    return columns()
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 325, in get_feature_names_out
    check_is_fitted(self, "n_features_in_")
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/validation.py", line 1721, in check_is_fitted
    raise NotFittedError(msg % {"name": type(estimator).__name__})
sklearn.exceptions.NotFittedError: This StackingClassifier instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.

  warnings.warn(
/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/model_selection/_validation.py:960: UserWarning: Scoring failed. The score on this train-test partition for these parameters will be set to nan. Details:
Traceback (most recent call last):
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/model_selection/_validation.py", line 949, in _score
    scores = scorer(estimator, X_test, y_test, **score_params)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/metrics/_scorer.py", line 537, in __call__
    return estimator.score(*args, **kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/julearn/pipeline/ju_pipeline.py", line 72, in score
    return super().score(X, y, sample_weight=sample_weight, **params)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/pipeline.py", line 1202, in score
    return self.steps[-1][1].score(Xt, y, **score_params)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/base.py", line 628, in score
    return accuracy_score(y, self.predict(X), sample_weight=sample_weight)
                             ~~~~~~~~~~~~^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 750, in predict
    y_pred = super().predict(X, **routed_params.final_estimator_["predict"])
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 373, in predict
    return self.final_estimator_.predict(self.transform(X), **predict_params)
                                         ~~~~~~~~~~~~~~^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 340, in wrapped
    return _wrap_data_with_container(method, data_to_wrap, X, self)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 315, in _wrap_data_with_container
    return adapter.create_container(
           ~~~~~~~~~~~~~~~~~~~~~~~~^
        data_to_wrap,
        ^^^^^^^^^^^^^
        original_input,
        ^^^^^^^^^^^^^^^
        columns=estimator.get_feature_names_out,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 122, in create_container
    columns = get_columns(columns)
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 30, in get_columns
    return columns()
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/ensemble/_stacking.py", line 325, in get_feature_names_out
    check_is_fitted(self, "n_features_in_")
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmponjkxoub/.venv/lib/python3.13/site-packages/sklearn/utils/validation.py", line 1721, in check_is_fitted
    raise NotFittedError(msg % {"name": type(estimator).__name__})
sklearn.exceptions.NotFittedError: This StackingClassifier instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.

  warnings.warn(
0   NaN
1   NaN
2   NaN
3   NaN
4   NaN
Name: test_score, dtype: float64

Total running time of the script: (0 minutes 4.877 seconds)

Gallery generated by Sphinx-Gallery