ajtulloch / svmpy

Basic soft-margin kernel SVM implementation in Python
251 stars 113 forks source link

svm using linear kernel can't solve some simple case #7

Open QiangZiBro opened 4 years ago

QiangZiBro commented 4 years ago

Hello,your code is great, but I tried a case with 3 points, using linear kernel, but it doesn't work out right answer, I don't know why, my test code is below:

    samples=np.array([[0,0],[1,1],[0,1]],dtype=np.float)
    labels=np.array([1,1,-1],dtype=np.float)

    trainer = svmpy.SVMTrainer(svmpy.Kernel.linear(), 0.5)
    predictor = trainer.train(samples, labels)
    print(predictor.predict([0,1])) #should output -1
Schuck9 commented 4 years ago

There is a mistake in computing bias .You can reffer the Jun-jie-Huang's issue to correct it. After I fixed the mistake ,it works in simple cases.

qiuxika commented 2 years ago

我根本不会改这个mistake,只好去用封装好的scikit-learn,结果。。。。太香了家人们!!!!