tests.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:primal_svm 作者: ksopyla 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号