我偶然发现了这个问题(当我使用K-fold训练大量数据时)
我遇到的问题与问题issue5150类似。但是,当我收到此警告“未找到权重中指定的类标签0”时,我甚至无法获得模型(内核是线性的)。
可以从https://github.com/scikit-learn/scikit-learn/issues/9494
复制x,y和w这是我的代码和错误:
>>> clf = SVC(C=0.5,class_weight='balanced',kernel='linear')
>>> clf.fit(x, y, sample_weight=w)
warning: class label 0 specified in weight is not found
SVC(C=0.5, cache_size=200, class_weight='balanced', coef0=0.0,
decision_function_shape=None, degree=3, gamma='auto', kernel='linear',
max_iter=-1, probability=False, random_state=None, shrinking=True,
tol=0.001, verbose=False)
>>> clf.coef_
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/xxx/lib/python2.7/site-packages/sklearn/svm/base.py", line 488, in coef_
coef = self._get_coef()
File "/xxx/lib/python2.7/site-packages/sklearn/svm/base.py", line 707, in _get_coef
if sp.issparse(coef[0]):
IndexError: list index out of range