def test_net_will_verify_bl2(self): for _ in range(0, 5): net = create_net() train_and_check(net, league='bl2') (verified, _) = verify(net, league='bl2', factor=0.85) if verified: break self.assertTrue(verified)
def test_after_serialize_same(self): net1 = create_net() result1 = train_and_check(net1) string = as_string(net1) net2 = from_string(string) result2 = train_and_check(net2, train_set=[]) self.assertEqual(result1.get_performance(), result2.get_performance())
def test_save_load_from_file(self): net1 = create_net() result1 = train_and_check(net1) filename = './prediction/pickles/test.pickle' save_net(net1, filename) net2 = load_net(filename) result2 = train_and_check(net2, train_set=[]) self.assertEqual(result1.get_performance(), result2.get_performance())
def test_training_improves(self): for _ in range(0, 3): result_1 = train_and_check(self.net, [], '2016') if result_1.get_performance() >= 50: self.net = create_net() else: break result_2 = train_and_check(self.net, ['2015'], '2016') self.assertGreater(result_2.get_performance(), result_1.get_performance()) self.is_in_range(result_2.get_performance(), 45, range_value=5) stats = result_2.get_statistics() self.assertGreater(stats[0], 2) self.assertGreater(stats[1], 5) self.assertGreater(stats[2], 3)
def test_dummy_pick_leader(self): self.net = PickLeader() self.trainer = NetTrainer(self.net) result = train_and_check(self.net, [], '2016') self.assertEqual(result.get_count(), 216) self.assertEqual(result.get_performance(), 47)
def test_not_trained_net(self): result = train_and_check(self.net, [], '2016') self.assertGreater(result.get_hits(), 0) self.assertEqual(result.get_count(), 216) self.assertGreater(result.get_performance(), 1) self.assertLess(result.get_performance(), 100)
def test_net_will_predict_each(self): net = create_net() result = train_and_check(net) stats = result.get_statistics() self.assertGreater(stats[0], 1) self.assertGreater(stats[1], 1) self.assertGreater(stats[2], 1)
def check_season_generic(self, season, train_seasons, expected_result): result = train_and_check(self.net, train_seasons, season) self.is_in_range(result.get_performance(), expected_result, range_value=5) stats = result.get_statistics() self.assertGreater(stats[0], 3) self.assertGreater(stats[1], 4) self.assertGreater(stats[2], 1)
def main(): x_axis = [] y_axis = [] n = 15 for i in range(0, n + 1): net = create_net() x_axis.append(i + 1) untrained = train_and_check(net, []) trained = train_and_check(net) verified = verify(net, delta=2) print 'Execution {0}:'.format(i+1), untrained.get_performance(),\ '=>', trained, 'verified:', verified y_axis.append(trained.get_performance()) show_plot(x_axis, y_axis, n)
def load_and_check(filename, league): logger = logging.getLogger() net = load_net(filename) query_stats = train_and_check(net, train_set=[]) logger.debug('using file %s', filename) logger.debug(query_stats) (_, verify_result) = verify(net, league=league) points = calculate_points(query_stats, verify_result) entry = NetEntry(filename, points, verify_result, query_stats) return (net, entry)
def main(): x_axis = [] y_axis = [] start = 5 n = 10 for i in range(start, start + n + 1): net = create_net(hidden_layer=i) x_axis.append(i) result = train_and_check(net) verified = verify(net) print 'Executed with', i, 'hidden layers:', result, 'verified', verified y_axis.append(result.get_performance()) show_plot(x_axis, y_axis, start + n)
def main(): x_axis = [] y_axis = [] step = 0.01 n = 20 for i in range(0, n + 1): alpha = step * i net = create_net(alpha=alpha) x_axis.append(alpha) result = train_and_check(net) verified = verify(net, delta=1) print 'Executed with alpha', i * step, ':', result, 'verified', verified y_axis.append(result.get_performance()) show_plot(x_axis, y_axis, n * step)
def main(): x_axis = [] y_axis = [] seasons = [ '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015' ] n = 25 step = 1 net = create_net(alpha=0.1) for i in range(step, n + 1, step): x_axis.append(i) result = train_and_check(net, max_iterations=step, train_set=seasons) verified = verify(net, delta=1) print 'Executed with ', i, 'iterations:', result, 'verified:', verified y_axis.append(result.get_performance()) show_plot(x_axis, y_axis, n)