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

Skip to content

Unnecessary call to check_X_y in RFE #10821

Closed
@jimmywan

Description

@jimmywan

Description

Can't use RFE/RFECV on X that is sparse(has NaN values) or y that is 2d.
Both of these decisions should be up to the underlying estimator.
The rejection of sparse X values does not make sense in a world with pipelines.
The reject of 2d output data should be up to the underlying estimator.

Steps/Code to Reproduce

Example partial stack trace from 2d y:

  File "/mypythoninstalldir/lib/python3.6/site-packages/sklearn/pipeline.py", line 250, in fit
    self._final_estimator.fit(Xt, y, **fit_params)
  File "/mypythoninstalldir/lib/python3.6/site-packages/sklearn/feature_selection/rfe.py", line 134, in fit
    return self._fit(X, y)
  File "/mypythoninstalldir/lib/python3.6/site-packages/sklearn/feature_selection/rfe.py", line 142, in _fit
    X, y = check_X_y(X, y, "csc")
  File "/mypythoninstalldir/lib/python3.6/site-packages/sklearn/utils/validation.py", line 578, in check_X_y
    y = column_or_1d(y, warn=True)
  File "/mypythoninstalldir/lib/python3.6/site-packages/sklearn/utils/validation.py", line 614, in column_or_1d
    raise ValueError("bad input shape {0}".format(shape))
ValueError: bad input shape (256, 2)

Expected Results

No error is thrown.

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