import sqlite3
from RankingAlgorithms import EloForTeams
import numpy as np

ELO_DEFAULT_RATING = 1200
ELO_DEFAULT_MAX = 1400
ELO_DEFAULT_MIN = 1000
elo_logistic = EloForTeams(x=16.359300036046655, y=397.8279040482779)
elo_normal = EloForTeams(distribution="normal", sigma=270.7020217152946)
dataset = sqlite3.connect('database.sqlite')
query = 'SELECT * FROM Match ORDER BY date ASC'

players_fetch = dataset.execute('SELECT player_api_id, overall_rating from Player_Attributes ORDER BY date ASC')

players_logistic = {}
players_normal = {}
overall_rating = {}

for row in players_fetch:
    if row[0] is not None and row[1] is not None:
        overall_rating[row[0]] = row[1]

r_max = max(overall_rating.values())
r_min = min(overall_rating.values())
for p,r in overall_rating.items():
    rating = ((r-r_min)/(r_max-r_min))*(ELO_DEFAULT_MAX-ELO_DEFAULT_MIN)+ELO_DEFAULT_MIN
    players_logistic[p] = rating
    players_normal[p] = rating

for i in range(0, 2):
    matches_fetch = dataset.execute(query)
import sqlite3
from RankingAlgorithms import EloForTeams
import numpy as np

ELO_DEFAULT_RATING = 1200
elo_logistic = EloForTeams()
elo_normal = EloForTeams(distribution="normal")
dataset = sqlite3.connect('database.sqlite')
players_logistic = {}
players_normal = {}
query = 'SELECT * FROM Match ORDER BY date ASC'

for i in range(0, 2):
    matches_fetch = dataset.execute(query)

    total_logistic = 0
    total_normal = 0
    predicted_logistic = 0
    predicted_normal = 0
    log_likelihood_logistic = 0
    log_likelihood_normal = 0

    for row in matches_fetch.fetchall():
        team1_logistic, team2_logistic = {}, {}
        team1_normal, team2_normal = {}, {}

        for index in range(55, 66):
            id = row[index]
            if id in players_logistic:
                team1_logistic[id] = players_logistic[id]
            else:
Exemple #3
0
    def get_ratings(self):
        return self.ratings

    def add_rating(self, date, rating):
        self.ratings[date] = rating

    def last_rating(self):
        return self.ratings[next(reversed(self.ratings))]


ELO_DEFAULT_RATING = 1200
dataset = sqlite3.connect('database.sqlite')

matches_fetch = dataset.execute(
    'SELECT * FROM Match WHERE country_id=1729 ORDER BY date ASC')
elo = EloForTeams()

# dictionary of players with database's player_api_id as key and a Player object as value
players = {}

for row in matches_fetch.fetchall():
    team1, team2 = {}, {}

    for index in range(55, 66):
        id = row[index]
        if id in players:
            team1[id] = players[id].last_rating()
        else:
            if id is not None:
                team1[id] = ELO_DEFAULT_RATING
Exemple #4
0
import sqlite3
from RankingAlgorithms import EloForTeams
import math

ELO_DEFAULT_RATING = 1200
ELO_DEFAULT_MIN = 1000
ELO_DEFAULT_MAX = 1400
dataset = sqlite3.connect('database.sqlite')
query = "SELECT * FROM Match ORDER BY date ASC"
elo = EloForTeams()

# assign players a default rating based on the overall_rating column
players_fetch = dataset.execute(
    'SELECT player_api_id, overall_rating from Player_Attributes')

players_o = {}
overall_rating = {}

for row in players_fetch:
    if row[0] is not None and row[1] is not None:
        overall_rating[row[0]] = row[1]

r_max = max(overall_rating.values())
r_min = min(overall_rating.values())
for p, r in overall_rating.items():
    players_o[p] = ((r - r_min) /
                    (r_max - r_min)) * (ELO_DEFAULT_MAX -
                                        ELO_DEFAULT_MIN) + ELO_DEFAULT_MIN

# calculate the percentage of draws in all matches
matches_fetch = dataset.execute(query)
import sqlite3
from RankingAlgorithms import EloForTeams
import pandas as pd
import matplotlib.pyplot as plt

elo = EloForTeams()
ELO_DEFAULT_RATING = 1200
dataset = sqlite3.connect('database.sqlite')
players = {}

df = pd.DataFrame(columns=['iteration', 'n_games'])

for i in range(1, 101):
    matches_fetch = dataset.execute('SELECT * FROM Match ORDER BY date ASC')

    total = 0
    well_predicted = 0
    for row in matches_fetch.fetchall():
        team1, team2 = {}, {}

        for index in range(55, 66):
            id = row[index]
            if id in players:
                team1[id] = players[id]
            else:
                if id is not None:
                    team1[id] = ELO_DEFAULT_RATING

        for index in range(66, 77):
            id = row[index]
            if id in players:
import sqlite3
from RankingAlgorithms import EloForTeams
import numpy as np

ELO_DEFAULT_RATING = 1200
elo_logistic = EloForTeams()
elo_normal = EloForTeams(distribution="normal")
dataset = sqlite3.connect('database.sqlite')
query = 'SELECT * FROM Match ORDER BY date ASC'
players_logistic_SA = {}
players_normal_SA = {}
players_logistic_CEM = {}
players_normal_CEM = {}
training_set_logistic_SA = []
training_set_normal_SA = []
training_set_logistic_CEM = []
training_set_normal_CEM = []

matches_fetch = dataset.execute(query)

for row in matches_fetch.fetchall():
    team1_logistic_SA, team2_logistic_SA = {}, {}
    team1_normal_SA, team2_normal_SA = {}, {}
    team1_logistic_CEM, team2_logistic_CEM = {}, {}
    team1_normal_CEM, team2_normal_CEM = {}, {}

    for index in range(55, 66):
        id = row[index]
        if id in players_logistic_SA:
            team1_logistic_SA[id] = players_logistic_SA[id]
        else:
Exemple #7
0
players = {}
overall_rating = {}

for row in players_fetch:
	if row[0] is not None and row[1] is not None:
		overall_rating[row[0]] = row[1]

r_max = max(overall_rating.values())
r_min = min(overall_rating.values())
for p,r in overall_rating.items():
	players[p] = ((r-r_min)/(r_max-r_min))*(ELO_DEFAULT_MAX-ELO_DEFAULT_MIN)+ELO_DEFAULT_MIN


matches_query = dataset.execute('SELECT * FROM Match WHERE country_id=1729 ORDER BY date ASC')
elo = EloForTeams()

matches_fetch = matches_query.fetchall()

matches_count = len(matches_fetch)
training_set_border = math.ceil(matches_count*TRANING_SET_SIZE)

training_set = []

matches_total = 0
draws = 0
for i in range(training_set_border):
	team1, team2 = {}, {}
	row = matches_fetch[i]

	for index in range(55, 66):