RuntimeError:分类程序未公开“ coef_”或“ feature_importances_”属性

时间:2018-10-15 23:00:24

标签: python runtime-error rfe

在我的代码中,它引发运行时错误。在这里,我试图将RFE拟合为回归数据。

from sklearn.feature_selection import RFE
from sklearn.svm import SVR           
from sklearn.feature_selection import SelectKBest
from sklearn.preprocessing import *

scaler = StandardScaler().fit(trainFeatures)
xscaled = scaler.transform(trainFeatures)
estimator = SVR()
selector = RFE(estimator, dimension, step=1)
selector = selector.fit(xscaled, trainOutput.ravel())
selectedFeatures = selector.transform(xscaled)

1 个答案:

答案 0 :(得分:1)

根据this link,RFE仅在内核为线性时才与SVR一起使用。

默认情况下,它是“ rbf”,请这样做:

estimator = SVR(kernel="linear")