当前位置: 首页>>代码示例>>Python>>正文


Python Optimizer.objective方法代码示例

本文整理汇总了Python中optimizer.Optimizer.objective方法的典型用法代码示例。如果您正苦于以下问题:Python Optimizer.objective方法的具体用法?Python Optimizer.objective怎么用?Python Optimizer.objective使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在optimizer.Optimizer的用法示例。


在下文中一共展示了Optimizer.objective方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_objective_single_game

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import objective [as 别名]
    def test_objective_single_game(self):
        o = Optimizer()
        o.load_games([(1, 2, 1, 1)])
        v1 = o.create_vars({1: {1: 2200}, 2: {1: 1800}}, [0, -1.01])
        v2 = o.create_vars({1: {1: 2200}, 2: {1: 2200}}, [0, -1.01])
        v3 = o.create_vars({1: {1: 1800}, 2: {1: 2200}}, [0, -1.01])

        (total1, likelihood1, regularization1, smoothness1,
         func_hard_reg, _) = o.objective(v1, verbose=True)
        self.assertLess(likelihood1, 0)
        self.assertTrue(1E-6 < regularization1 < 1)
        self.assertEqual(smoothness1, 0)
        self.assertTrue(func_hard_reg < 1)

        (total2, likelihood2, regularization2, _, _, _) = o.objective(
            v2, verbose=True)
        self.assertLess(likelihood2, likelihood1)

        (total3, likelihood3, regularization3, _, _, _) = o.objective(
            v3, verbose=True)
        self.assertAlmostEqual(regularization1, regularization3)


        self.assertLess(total1 / total2, 0.9)
        self.assertLess(total2 / total3, 0.9)
开发者ID:eterevsky,项目名称:gamerank,代码行数:27,代码来源:test_optimizer.py

示例2: test_objective_draw

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import objective [as 别名]
    def test_objective_draw(self):
        o = Optimizer(rating_reg=0)
        o.load_games([(1, 2, 1, 2), (2, 1, 1, 2)])

        v1 = o.create_vars({1: {1: 2200}, 2: {1: 1800}}, [0, -1.01])
        v2 = o.create_vars({1: {1: 2000}, 2: {1: 2000}}, [0, -1.01])
        v3 = o.create_vars({1: {1: 1800}, 2: {1: 2200}}, [0, -1.01])

        self.assertLess(o.objective(v2), o.objective(v1))
        self.assertLess(o.objective(v2), o.objective(v3))
开发者ID:eterevsky,项目名称:gamerank,代码行数:12,代码来源:test_optimizer.py

示例3: test_objective_symmetric_wins

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import objective [as 别名]
    def test_objective_symmetric_wins(self):
        o = Optimizer(rating_reg=0)
        o.load_games([(1, 2, 1, 1), (2, 1, 1, 1)])

        v1 = o.create_vars({1: {1: 2200}, 2: {1: 1800}}, [0, -1.01])
        v2 = o.create_vars({1: {1: 2000}, 2: {1: 2000}}, [0, -1.01])
        v3 = o.create_vars({1: {1: 1800}, 2: {1: 2200}}, [0, -1.01])

        self.assertLess(o.objective(v2) / o.objective(v1), 0.9)
        self.assertLess(o.objective(v2) / o.objective(v3), 0.9)
开发者ID:eterevsky,项目名称:gamerank,代码行数:12,代码来源:test_optimizer.py

示例4: test_single_game

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import objective [as 别名]
    def test_single_game(self):
        o = Optimizer(rand_seed=239)
        o.load_games([(1, 2, 1, 1)])
        ratings, f, v = o.run()
        (total, likelihood, regularization, smoothness,
         func_hard_reg, func_soft_reg) = o.objective(v, verbose=True)
        self.assertTrue(100 < ratings[1][1] < 4000)
        self.assertTrue(100 < ratings[2][1] < 4000)
        self.assertGreater(
            f.calc(convert_rating_diff(ratings[1][1] - ratings[2][1])), 0.5)
        self.assertGreater(ratings[1][1], ratings[2][1])

        total = o.objective(v)
开发者ID:eterevsky,项目名称:gamerank,代码行数:15,代码来源:test_optimizer.py

示例5: test_objective_time_reg

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import objective [as 别名]
 def test_objective_time_reg(self):
     o = Optimizer(rand_seed=239)
     o.load_games([(1, 2, 1, 1), (1, 2, 2, 0)])
     v = o.create_vars({1: {1: 2200, 2: 1800}, 2: {1: 1800, 2: 2200}},
                       (0, -1.01))
     (total, likelihood, regularization, _, _, _) = o.objective(
          v, verbose=True)
     self.assertLess(likelihood, 0)
     self.assertTrue(1E-6 < regularization < 1)
开发者ID:eterevsky,项目名称:gamerank,代码行数:11,代码来源:test_optimizer.py

示例6: test_time_regularization

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import objective [as 别名]
    def test_time_regularization(self):
        o = Optimizer(rand_seed=239)
        o.load_games([(1, 2, 1, 1), (2, 1, 1, 0), (1, 2, 2, 0), (2, 1, 2, 1)])
        rating, f, v = o.run()

        (total1, _, reg, smoothness1, func_hard_reg,
         func_soft_reg) = o.objective(v, verbose=True)
        self.assertLess(func_hard_reg, 1)
        self.assertGreater(smoothness1, 0.001)

        self.assertGreater(rating[1][1], rating[1][2])
        self.assertLess(rating[2][1], rating[2][2])
        self.assertGreater(rating[1][1], rating[2][1])
        self.assertLess(rating[1][2], rating[2][2])
        prob1 = f.calc(convert_rating_diff(rating[1][1] - rating[2][1]))
        self.assertGreater(prob1, 0.51)
        prob2 = f.calc(convert_rating_diff(rating[1][2] - rating[2][2]))
        self.assertLess(prob2, 0.49)
开发者ID:eterevsky,项目名称:gamerank,代码行数:20,代码来源:test_optimizer.py


注:本文中的optimizer.Optimizer.objective方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。