-
-
Notifications
You must be signed in to change notification settings - Fork 25.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsupported multioutput stacking regressor #25597
Comments
Thank you for opening the issue! In this case, the documentation is incorrect, because Lines 874 to 876 in 4810fab
I opened #25599 to correct the docstring for |
Can I work on this issue |
@sanjail3 As stated in #25597 (comment), I already opened #25599 to fix the docstring. |
Describe the bug
The method
fit_transform
ofsklearn.ensemble.StackingRegressor
, according to the documentation, should support as second argument (y
) an array-like of shape (n_samples,) or (n_samples, n_outputs). However, if an array of shape (n_sample, n_outputs) is provided the following error is retrieved:Steps/Code to Reproduce
Expected Results
Train stacking model and transform input.
Actual Results
ValueError Traceback (most recent call last)
Cell In [14], line 12
9 final_estimator = ElasticNet(max_iter=10000)
10 stacking_regressor = StackingRegressor(estimators=estimators, final_estimator=final_estimator)
---> 12 stacking_regressor.fit_transform(X, y)
File /lib/python3.10/site-packages/sklearn/utils/_set_output.py:142, in _wrap_method_output..wrapped(self, X, *args, **kwargs)
140 @wraps(f)
141 def wrapped(self, X, *args, **kwargs):
--> 142 data_to_wrap = f(self, X, *args, **kwargs)
143 if isinstance(data_to_wrap, tuple):
144 # only wrap the first output for cross decomposition
145 return (
146 _wrap_data_with_container(method, data_to_wrap[0], X, self),
147 *data_to_wrap[1:],
148 )
File /lib/python3.10/site-packages/sklearn/base.py:862, in TransformerMixin.fit_transform(self, X, y, **fit_params)
859 return self.fit(X, **fit_params).transform(X)
860 else:
861 # fit method of arity 2 (supervised transformation)
--> 862 return self.fit(X, y, **fit_params).transform(X)
File /lib/python3.10/site-packages/sklearn/ensemble/_stacking.py:957, in StackingRegressor.fit(self, X, y, sample_weight)
...
-> 1202 raise ValueError(
1203 "y should be a 1d array, got an array of shape {} instead.".format(shape)
1204 )
ValueError: y should be a 1d array, got an array of shape (100, 2) instead.
Versions
The text was updated successfully, but these errors were encountered: