def test_optimized(self):
"""
Test if optimized works well
"""
lr = self.logistic_regression
lr.set_data(self.iris)
op_theta = lr.optimized()
self.assertEqual(len(op_theta), 4)
# check if really minimal, function is monotonic so everywhere around
# j should be higher
self.assertLessEqual(
lr.j(op_theta), lr.j(op_theta + np.array([1, 0, 0, 0])))
self.assertLessEqual(
lr.j(op_theta), lr.j(op_theta + np.array([0, 1, 0, 0])))
self.assertLessEqual(
lr.j(op_theta), lr.j(op_theta + np.array([0, 0, 1, 0])))
self.assertLessEqual(
lr.j(op_theta), lr.j(op_theta + np.array([0, 0, 0, 1])))
test_logistic_regression.py 文件源码
python
阅读 32
收藏 0
点赞 0
评论 0
评论列表
文章目录