[ACCEPTED]-ValueError using recursive feature elimination for SVM with rbf kernel in scikit-learn-rfe

Accepted answer
Score: 11

This seems to the expected outcome. RFECV requires 15 the estimator to have an coef_ which signifies 14 the feature importances:

estimator : object

A 13 supervised learning estimator with a fit 12 method that updates a coef_ attribute that 11 holds the fitted parameters. Important features 10 must correspond to high absolute values 9 in the coef_ array.

By changing the kernel 8 to RBF, the SVC is no longer linear and the 7 coef_ attribute becomes unavailable, according 6 to the documentation:

coef_

array, shape = [n_class-1, n_features]

Weights 5 asigned to the features (coefficients in 4 the primal problem). This is only available 3 in the case of linear kernel.

The error is 2 raised by SVC (source) when RFECV is trying to access 1 coef_ when the kernel is not linear.

More Related questions