Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Issue with predict function of MultiOutputRegressor when used with StackingRegressor #16549

@prabal27

Description

@prabal27

Describe the bug

An error is raised when I was trying to use MultiOutputRegressor along with StackingRegressor.

ValueError                                Traceback (most recent call last)
<ipython-input-43-e4eb1ec64c28> in <module>
----> 1 reg.predict(X_train_norm)

~\Anaconda3\lib\site-packages\sklearn\multioutput.py in predict(self, X)
    188         check_is_fitted(self)
    189         if not hasattr(self.estimator, "predict"):
--> 190             raise ValueError("The base estimator should implement"
    191                              " a predict method")
    192 

ValueError: The base estimator should implement a predict method

-->

Steps/Code to Reproduce

Example:

reg=MultiOutputRegressor(StackingRegressor
            (estimators=estimators,final_estimator=ExtraTreesRegressor(n_estimators=100)))
reg.fit(X_train_norm, y_train)
reg.predict(X_train_norm)

Expected Results

The expected result should be an array of predicted values.

Actual Results

raise ValueError("The base estimator should implement"
    191                              " a predict method")

Versions

For scikit-learn >= 0.22.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions