And*_*nks 5 machine-learning scikit-learn
我有2000个标记数据(7种不同标签)和大约100K未标记数据,我正在尝试使用sklearn.semi_supervised.LabelPropagation.数据有1024个维度.我的问题是分类器将所有内容标记为1.我的代码如下所示:
X_unlabeled = X_unlabeled[:10000, :]
X_both = np.vstack((X_train, X_unlabeled))
y_both = np.append(y_train, -np.ones((X_unlabeled.shape[0],)))
clf = LabelPropagation(max_iter=100).fit(X_both, y_both)
y_pred = clf.predict(X_test)
Run Code Online (Sandbox Code Playgroud)
y_pred是所有的.此外,X_train是2000x1024并且X_unlabeled是未标记数据的子集10000x1024.
在分类器上调用fit时,我也会收到此错误:
/usr/local/lib/python2.7/site-packages/sklearn/semi_supervised/label_propagation.py:255:RuntimeWarning:在self.label_distributions_/= normalizer中遇到无效值
您是否尝试过伽马参数的不同值?由于该图是通过计算 rbf 核构建的,因此计算包括指数,如果该值是太大的负数,则 python 指数函数返回 0(请参阅http://computer-programming-forum.com/56-python/ ef71e144330ffbc2.htm)。如果图表填充 0,则 label_distributions_ 填充“nan”(因为标准化)并出现警告。(注意,scikit实现中的gamma值乘以欧氏距离,这与Zhu论文中的不是一回事。)