def test_obj_value_points_correctly_class_close_to_hyperplane(self):
bias = 0.0
w = np.array([-1, 1, bias])
l = self.svm.l2reg
X = np.array([[0.5, 0.3], [1, 0.8], [1, 1.4], [0.6, 0.9]])
Y = np.array([-1, -1, 1, 1])
# compute loss for all X -> 1-yi*(xi*w+b)
out = np.fmax(0, 1 - Y * (X.dot(w[0:-1]) + w[-1]))
expectedObj = 2.0650000000000004
result, _ = self.svm._obj_func(w, X, Y, out)
self.assertAlmostEqual(expectedObj, result)
评论列表
文章目录