gpt4 book ai didi

python - 运行时错误: The classifier does not expose "coef_" or "feature_importances_" attributes

转载 作者:行者123 更新时间:2023-12-01 08:55:02 24 4
gpt4 key购买 nike

在我的代码中,它引发运行时错误。在这里,我尝试将 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)

最佳答案

根据this link ,RFE仅在内核线性时与SVR一起工作。

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

estimator = SVR(kernel="linear")

关于python - 运行时错误: The classifier does not expose "coef_" or "feature_importances_" attributes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52825810/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com