一个类有大约 100 个数据元素,另一个类有大约 6000 个数据元素。当我使用数据创建 svm 时,它只返回我尝试预测的每个新元素的多数类别标签。有没有办法用 sklearn svm 来惩罚少数类别的错误分类,这样我就可以实际使用我的所有数据元素,而不必从多数类别中抽取 100 个元素用于测试?
请您参考如下方法:
SVC 有以下参数你可以使用
class_weight : {dict, 'auto'}, optional
Set the parameter C of class i to class_weight[i]*C for
SVC. If not given, all classes are supposed to have
weight one. The 'auto' mode uses the values of y to
automatically adjust weights inversely proportional to
class frequencies.
