Beispiel #1
0
def topPlayerEvolution():
    retVal = dict()
    
    leagues = utils.getAllDatafromTable('league')
    teams = utils.getAllDatafromTable('team')
    matches = utils.getAllDatafromTable('match')
    leagueNameMap = dict()
    for league in leagues:
        leagueNameMap[league[0]] = league[2]
    teamNameMap = dict()
    for team in teams:
        teamNameMap[team[1]] = team[3]
    leagueTeamMap = dict()
    for match in matches:
        if leagueTeamMap.get(match[2]) is None:leagueTeamMap[match[2]]=set()
        
        leagueTeamMap.get(match[2]).add(match[7])
        leagueTeamMap.get(match[2]).add(match[8])
    
    retVal1= dict()
    for league in leagueTeamMap.keys():
        leagueName = leagueNameMap.get(league)
        #print(leagueName)
        retVal1[leagueName] = []
        teams = list(leagueTeamMap.get(league))
        if league == 1729:print(teams)
        #print(teams)
        for team in teams:
            #if league == 1729:
            #    print("adding team for england")
            #retVal1[leagueName]["id"] = team
            #retVal1[leagueName]["name"] = teamNameMap.get(team)
            retVal1[leagueName].append({"id":team,"name":teamNameMap.get(team)})
    print(retVal1.get('England Premier League'))
    return retVal1
def generateLeagueData():
    countries = utils.getAllDatafromTable('Country')
    matches = utils.getAllDatafromTable('Match')
    leagues = utils.getAllDatafromTable('League')
    teams = utils.getAllDatafromTable('Team')
    countryId = [row[0] for row in countries]
    mergedLeagueCountry = generateMergedLeagueCountryData(
        countryId, countries, leagues)
    filteredMatches = getFilteredMatches(matches, mergedLeagueCountry)
    filteredMatches = utils.removeNan(filteredMatches)
    matchEntropies = list(map(utils.calculateEntropy, filteredMatches))
    entropyLeagueDict = getEntropyLeagueDict(filteredMatches, matchEntropies)
    saveToFile(entropyLeagueDict, leagues)
    getLeagueTeamEntropyDict(matchEntropies, filteredMatches, leagues, teams)
Beispiel #3
0
def getTopPlayerEvolution(leagueId, teamId):
    leagues = utils.getAllDatafromTable('league')
    leagueName = ''
    teamName = ''
    for league in leagues:
        if league[0] == leagueId: leagueName = league[2]
    teams = utils.getAllDatafromTable('team')
    for team in teams:
        if team[1] == teamId: teamName = team[3]
    #print(minedLeagueData[0].keys())
    t = minedLeagueData[0].get(leagueName).get(teamName)
    resp = flask.Response(json.dumps(t))
    resp.headers['Access-Control-Allow-Origin'] = "*"
    return resp
Beispiel #4
0
def getLeagueTeams(leagueId):
    leagues = utils.getAllDatafromTable('league')
    leagueName = ''
    for league in leagues:
        if league[0] == leagueId: leagueName = league[2]
    t = minedLeagueData[1].get(leagueName)
    resp = flask.Response(json.dumps(t))
    resp.headers['Access-Control-Allow-Origin'] = "*"
    return resp
Beispiel #5
0
def test(leagueId):
    from flask import jsonify
    leagues = utils.getAllDatafromTable('league')
    leagueName=''
    for league in leagues:
        if league[0] == leagueId:leagueName = league[2]

    #print(leagueName)
    
    x = topPlayerEvolution()
    #print(leagueName in x.keys())
    #print(x.keys())
    #print(x.values())
    return (x.get(leagueName))
Beispiel #6
0
import json
from lib import utils
countries = utils.getAllDatafromTable('Country')
matches = utils.getAllDatafromTable('Match')
leagues = utils.getAllDatafromTable('League')
teams = utils.getAllDatafromTable('Team')
players = utils.getAllDatafromTable('player_attributes')
leagueNames = []
myMap = dict()
myMap["teams"] = []
for league in leagues:
    myMap["teams"].append(league[2])
    leagueNames.append(league[2])

myMap["graphs"] = dict()
for t in leagueNames:
    myMap["graphs"][t] = dict()
    myMap["graphs"][t]["nodes"] = []
    myMap["graphs"][t]["links"] = []
#filteredPlayers = utils.removeNan(players)
#filteredPlayers = [player for player in filteredPlayers if player[4]>=80]
leaguePlayer = dict()
visitedPlayers = set()
matches = utils.removeNan(matches)
playerRatingMap = dict()
for player in players:
    playerRatingMap[player[0]] = player[4]
print(playerRatingMap)
for match in matches:
    league = match[2]
    players = match[55:77]
Beispiel #7
0
from lib import utils
import numpy as np
leagues = utils.getAllDatafromTable('league')
countries = utils.getAllDatafromTable('country')
countryNameMap = dict()
for country in countries:
    countryNameMap[country[0]] = country[1]
matches = utils.getAllDatafromTable('match')
leagueScoreMap = dict()
for league in leagues:
    leagueScoreMap[league[0]] = []
for match in matches:
    home_team_goals = int(match[9])
    away_team_goals = int(match[10])
    if home_team_goals == away_team_goals:
        home_team_score = 1
        away_team_score = 1
    elif home_team_goals > away_team_goals:
        home_team_score = 3
        away_team_score = 0
    else:
        away_team_score = 3
        home_team_score = 0
    leagueScoreMap[match[2]].append([home_team_score, away_team_score])
avgLeagueScore = dict()
for league in leagueScoreMap.keys():
    scores = leagueScoreMap.get(league)
    avg_home_score = np.mean([score[0] for score in scores])
    avg_away_score = np.mean([score[1] for score in scores])
    avgLeagueScore[league] = [avg_home_score, avg_away_score]
data = []
Beispiel #8
0
from lib.db import Database
from lib import utils
import random
import json
if __name__ == '__main__':
    obj = Database()
    obj.cursor.execute('select * from player_attributes')
    print("Total Teams= " + str(len(utils.getAllDatafromTable('team'))))
    print("Total Players= " + str(len(utils.getAllDatafromTable('player'))))
    #utils.prediction1()