コード例 #1
0
    def setUp(self):
        #testing reference http://www.zerozero.pt/edition.php?jornada_in=19&id_edicao=86785&fase=81592
        eng_dao_15_16 = DAO(country="england",
                            season="15-16",
                            cols="sport_cols")
        self.league = League(eng_dao_15_16)

        spa_dao_15_16 = DAO(country="spain", season="15-16", cols="sport_cols")
        self.league_spa = League(spa_dao_15_16)
コード例 #2
0
	def test_paired_points(self):
		eng_dao_16_17 = DAO(country="england", season="16-17", cols="sport_cols")
		eng_league = League(eng_dao_16_17)
		eng_league_anl = LeagueAnalysis(league=eng_league)

		n_round = 18

		five_dates = [eng_league.date_by_round(round_n) for round_n in range(n_round - 4, n_round + 1)]
		
		date1 = five_dates[0]
		date2 = five_dates[-1]
		
		df1 = eng_league.table(to_date=date1)
		df2 = eng_league.table(to_date=date2)

        # Chelsea		34 46	Chelsea
        # Arsenal		31 40	Liverpool
        # Liverpool		30 39	Man City
        # Man City		30 37	Arsenal
        # Tottenham		27 36	Tottenham

		points1, points2 = eng_league_anl.paired_points(df1, df2, n_head=5)

		self.assertEqual(points1.tolist(), [34, 31, 30, 30, 27])
		self.assertEqual(points2.tolist(), [46, 37, 40, 39, 36])
コード例 #3
0
    def setUp(self):
        if os.path.exists('stock.db'):
            os.remove('stock.db')

        self.dao = DAO()
        self.dao.connect()
        self.dao.create_db()

        self.ds = SinaDS()
コード例 #4
0
def create_dao(db: str) -> BaseDAO:
    if db == 'mongo':
        config = json.load(open(relative(__file__,
                                         "config/mongoconfig.json")), )
        return MongoDAO(
            host=config["host"],
            port=config["port"],
            db_name=config["dbName"],
        )
    elif db == 'mysql':
        return DAO()
コード例 #5
0
	def test_range_points_spread(self):
		spain_dao = DAO(country="spain", season="16-17", cols="sport_cols")
		league = League(spain_dao)
		league_anl = LeagueAnalysis(league=league)
		
		dates = ['2016/11/28', '2016/12/05', '2016/12/12', '2016/12/19', '2017/01/09', '2017/01/16', '2017/01/22']

		# for date in dates:
		# 	print()
		# 	print(league.table(to_date=date))

		range_points_spread = league_anl.range_points_spread(dates=dates, top_n_clubs=6)

		self.assertEqual([11, 11, 12, 9, 11, 9, 12], range_points_spread)
コード例 #6
0
	def test_points_corr(self):
		eng_dao_16_17 = DAO(country="england", season="16-17", cols="sport_cols")
		eng_league = League(eng_dao_16_17)
		eng_league_anl = LeagueAnalysis(league=eng_league)
		n_round = 18

		date1 = "2016-12-28"
		table_df1 = eng_league.table(to_date=date1)

		corr1 = eng_league_anl.points_corr(df_tables=[table_df1, table_df1], method="spearman", n_head=10)
		self.assertLess(0.98, corr1[0])

		date2 = "2016-12-05"
		table_df2 = eng_league.table(to_date=date2)

		corr2 = eng_league_anl.points_corr(df_tables=[table_df1, table_df2], method="spearman", n_head=5)
		self.assertLess(0.665, corr2[0])
		self.assertGreater(0.669, corr2[0])
コード例 #7
0
	def setUp(self):
		#testing reference http://www.zerozero.pt/edition.php?jornada_in=19&id_edicao=86785&fase=81592
		dao = DAO(country="england", season="15-16", cols="sport_cols")
		self.grouped_stats = GroupedStats(dao)
コード例 #8
0
import pandas as pd
from dao.dao import DAO
from table import Table

data = DAO().get_data("spain", "15-16", cols="sport_cols")
print(data.head())

table = Table(data)
table.league_progress_by_date("15/01/2016")
table.matches_played("15/01/2016")
コード例 #9
0
def mysql_init():
    dao = DAO()
    init_db(dao)
コード例 #10
0
ファイル: main.py プロジェクト: Kopachelli/league_analytics
from dao.dao import DAO
from grouped_stats import GroupedStats
from table import Table
from dates import next_day
from analysis import Analysis, CORRELATION_H1_H2, CORRELATION_H1_FULL, CORRELATION_H2_FULL

dao = DAO(country="england", season="15-16", cols="sport_cols")
stats = GroupedStats(dao.get_data())

print("")

table = Table(dao)
points = table.points()
print ("Final table")
print (points)
print()

### FIRST HALF LEAGUE
half_league_date = table.half_league_date()
print(half_league_date)

eng_points_h1 = table.points(to_date=half_league_date)
eng_points_h2 = table.points(from_date=next_day(half_league_date))

print("England First Half")
print(eng_points_h1.sort_values(by="Points", ascending=False))
print()
print("England Second Half")
print(eng_points_h2.sort_values(by="Points", ascending=False))
print()