At this link, there is an example of finding feature ranking using RFE in SVM linear kernel.

If I want to check feature ranking in other SVM kernel (eg. rbf, poly etc).How to do it?

I have changed the kernel in the code from SVR(kernel="linear") to SVR(kernel="rbf"),

from sklearn.datasets import make_friedman1
from sklearn.feature_selection import RFE
from sklearn.svm import SVR
X, y = make_friedman1(n_samples=50, n_features=10, random_state=0)
estimator = SVR(kernel="linear")
selector = RFE(estimator, 5, step=1)
selector = selector.fit(X, y)

and then I get this error

ValueError: coef_ is only available when using a linear kernel

Question: How to check feature ranking in other SVM kernels eg rbf, poly etc?


1 Answer 1


To use RFE, it is a must to have a supervised learning estimator which attribute coef_ is available, this is the case of the linear kernel. The error you are getting is because coef_ is not for SVM using kernels different from Linear. It is in RFE documentation

A walk-around solution is presented in Feature selection for support vector machines with RBF kernel by Quanzhong Liu et. al.

  • 1
    $\begingroup$ I dont understand what was the the point of giving -ve points on this question. I am clearly asking how to check feature ranking in other SVM kernels (which are not linear) $\endgroup$
    – Umar
    May 31, 2016 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.