一个Class SVM无法对训练集进行分类

时间:2018-07-12 09:35:02

标签: machine-learning classification svm

我目前正在一个项目中,将时间序列的窗口分类为OCSVM的轮廓线/内线。在进行一些测试时,我偶然发现以下问题/问题:

>>> from sklearn import svm
>>> train = [(0,0,0),(0,0,1),(1,1,1)]
... 
>>> clf = svm.OneClassSVM()
... 
>>> clf.fit(train)
OneClassSVM(cache_size=200, coef0=0.0, degree=3, gamma='auto', kernel='rbf',
      max_iter=-1, nu=0.5, random_state=None, shrinking=True, tol=0.001,
      verbose=False)
>>> clf.predict(train)
array([-1, -1,  1])

为什么分类器在这里失败? -1表示大纲...但是我正在预测训练集吗?因此,所有参数都应为1(线性)。

我想念什么?有什么想法吗?

最诚挚的问候

1 个答案:

答案 0 :(得分:0)

看看docs,似乎Public Class Form1 Private Sub btnChooseColor_Click(sender As Object, e As EventArgs) Handles btnChooseColor.Click 'I'm assuming that dlgColorDialog has been placed using the Forms designer. dlgColorDialog.ShowDialog() End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'Load the custom colors from My.Settings into the dialog when the form loads. dlgColorDialog.CustomColors = My.Settings.CustomColors End Sub Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing 'Save the custom colors when the form closes. My.Settings.CustomColors = dlgColorDialog.CustomColors My.Settings.Save() End Sub End Class 参数默认为0.5会限制训练误差和支持向量,并且由于0.5 * 3(训练示例)为1.5,因此培训持续进行,直到正确分类了一个或两个示例。

调整nu值应有助于您对更多的点进行分类,但可能会导致拟合过度。