machine-learning - Scikits 学习 : feature weight in Linear kernel SVM

标签 machine-learning svm scikits feature-selection scikit-learn

我正在处理文本分类问题(情感分析)。我想知道 scikit-learn 中是否有任何选项可以为功能添加“权重”(作为重要性的衡量标准)。我检查了文档,发现 the attribute "coefs" of SVC ,定义如下:

    coef_   array, shape = [n_class-1, n_features]  
    Weights asigned to the features (coefficients in the primal problem). 
   This is only available in the case of linear kernel.coef_ is readonly property derived from dual_coef_ and support_vectors_ 

但是,该属性似乎是只读的。

最佳答案

coef_ 向量是机器学习算法学习到的参数的 View 。手动设置它们没有意义,因为它们是根据数据自动调整的。你可以做的是:

  • 如果您事先知道某些类别比其他类别更重要,请设置 class_weight

  • 如果您事先了解某些样本(数据集中的行)比其他样本更重要,则设置sample_weight

  • 重新缩放特征以使某些特征比其他特征具有更大的方差,例如,如果您使用 RBF 内核并且希望某些特征比其他特征更重要(通常最好将所有特征缩放到单位方差)

  • 如果您使用内核并希望以这种方式编码特殊的先验知识,请使用自定义的预计算内核。

对于文本分类,数据非常暗淡,内核通常只是浪费资源而几乎没有或根本没有增加预测准确性,因此最后两点可能与您的具体问题无关。

关于machine-learning - Scikits 学习 : feature weight in Linear kernel SVM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11075556/

相关文章:

logging - Tensorflow Estimator 打印损失时使用什么数据集

c++ - OpenCV - 样本 SVM 的集合

python - Scikit 多类分类指标,分类报告

python - 如何在训练期间从 Scikit Learn SVM 中的每个类中抽取相同数量的示例?

python - 由多个激活函数组成的神经网络

machine-learning - Scikit 学习支持向量机的多类分类

python - Sklearn MLP 分类器超参数优化 (RandomizedSearchCV)

python - 并非所有类别都存在时的虚拟变量

algorithm - 如何将强化学习应用于连续 Action 空间?

kernel - 选择 c 和 gamma 值