未找到类标签sklearn错误

时间:2015-08-19 08:53:16

标签: python machine-learning scikit-learn svm

错误:

warning: class label 1 specified in weight is not found
warning: class label 1 specified in weight is not found
warning: class label 1 specified in weight is not found
warning: class label 1 specified in weight is not found
warning: class label 1 specified in weight is not found
warning: class label 1 specified in weight is not found
warning: class label 1 specified in weight is not found
warning: class label 1 specified in weight is not found
warning: class label 1 specified in weight is not found


def BaggingClassifierSVM(X_train,y):
    n_estimators = 10
    subsample_train=2000
    X_train=X_train[::subsample_train,:]
    y=y[::subsample_train,:]
    clf = OneVsRestClassifier(BaggingClassifier(SVC(kernel='linear', probability=True, class_weight='auto'), max_samples=1.0 / n_estimators, n_estimators=n_estimators))
    clf.fit(X_train,y)
    return clf

不了解错误,在学习linearSVC时没有得到。并且还可以在其他数据集(如虹膜)上使用BAggingClassifier。感谢。

编辑:

Dataset-> https://drive.google.com/folderview?id=0B16PrXUjs69zfmpMYk1mcnlfWDlTdjBUUWFHaHNrT2ZQY2RJNUVKbUVIRDJXMHU0R1h5R0k&usp=sharing

使用np.load(<filepath>)

1 个答案:

答案 0 :(得分:0)

正如我发现的那样 - 这是sklearn SVM实现中的错误,似乎只有在与Bagging一起使用时才会出现。要重现它,您只需将sample_weights参数传递给fit方法,其中某些类的样本的权重完全归零。当Bagging算法随机抽取sample_weights为基本估算器创建子集时,这就是隐含发生的情况。它倾向于排除大多数类,并且在这种SVM实现的情况下,它会导致错误。

我会报告这个错误。您可以使用其他基本估算器,或使用其他合奏方法代替套袋,而不是使用SVM,它可能对您有帮助。