部分代码
from sklearn.feature_selection import RFE, RFECV
from sklearn.svm import SVC, SVR
import pandas as pd
df = pd.read_csv('XXX.csv', encoding='gbk')
print(df.head())
df.label=df.label.astype(str)
y=df.label
print("y的内容是:",y)
print(y.head())
x=df.drop('label', axis=1)
print(x.head())
features = x
print('开始训练特征')
svc = SVC(kernel="linear", C=1)
rfe = RFE(estimator=svc, n_features_to_select=1, step=1)
......
完整代码链接:在Sklearn中使用SVC运行RFE的python代码