关于特征选择的问题,如何解决?(语言-python)

我受不了了 rfecv拿过来做特征筛选 放的是svm linear就可以用 换成rbf就报错
f"when importance_getter=='auto', the underlying "
ValueError: when importance_getter=='auto', the underlying estimator SVC should have coef_ or feature_importances_ attribute. Either pass a fitted estimator to feature selector or call fit before calling transform.

我的问题第一个是为什么会出现这种情况
第二个问题是importance——getter有几种参数
第三个问题是svc好像没有coef——和feature——importances

不知道你这个问题是否已经解决, 如果还没有解决的话:
  • 你可以参考下这个问题的回答, 看看是否对你有帮助, 链接: https://ask.csdn.net/questions/7674804
  • 这篇博客也不错, 你可以看下纯小白Python爬取东方财富网研报内容并通过机器学习的SVM模型进行文本分析(四)
  • 除此之外, 这篇博客: 基于Python的SVM算法深入研究中的 (一)非标准化原始数据显示 部分也许能够解决你的问题, 你可以仔细阅读以下内容或者直接跳转源博客中阅读:

    Python代码

    import numpy as np
    import matplotlib.pyplot as plt
    
    from sklearn import datasets
    from sklearn.preprocessing import StandardScaler
    from sklearn.svm import LinearSVC
    
    iris = datasets.load_iris()
    
    X = iris.data
    y = iris.target
    
    X = X [y<2,:2] #只取y<2的类别,也就是0 1 并且只取前两个特征
    y = y[y<2] # 只取y<2的类别
    
    # 分别画出类别0和1的点
    plt.scatter(X[y==0,0],X[y==0,1],color='red') 
    plt.scatter(X[y==1,0],X[y==1,1],color='blue')
    plt.show()
    
    # 标准化
    standardScaler = StandardScaler()
    
    standardScaler.fit(X) #计算训练数据的均值和方差
    X_standard = standardScaler.transform(X) #再用scaler中的均值和方差来转换X,使X标准化
    
    svc = LinearSVC(C=1e9) #线性SVM分类器
    svc.fit(X_standard,y) # 训练svm
    

    数据显示结果
    在这里插入图片描述


如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^