def test_obj_value_points_correctly_class_far_from_hyperplane(self):
bias = 0.0
w = np.array([-1, 1, bias])
l = self.svm.l2reg
X = np.array([[5, 0.3], [1, -0.8], [1, 6], [-0.6, 3]])
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 = 1.0
result, _ = self.svm._obj_func(w, X, Y, out)
self.assertAlmostEqual(expectedObj, result)
评论列表
文章目录