from sklearn.datasets import make_friedman1
from sklearn.feature_selection import RFECV
from sklearn.svm import SVR
import pandas
from sklearn.preprocessing import scale
data = pandas.read_csv("iris.csv")
print(data)
print(data.shape)
X = data.iloc[:,0:-1]
#def z_score(x):
X = scale(X)
y = data.iloc[:,-1]
print(X.shape)
estimator = SVR(kernel="linear")
selector = RFECV(estimator, step=1, cv=5)
selector = selector.fit(X, y)
print(selector.support_)
print(selector.ranking_)
本文通过Python代码演示了如何使用递归特征消除与交叉验证(RFECV)进行特征选择的过程。利用sklearn库中的SVR作为基模型,对Iris数据集进行特征重要性评估,并展示了特征选择的结果。
881

被折叠的 条评论
为什么被折叠?



