コード例 #1
0
ファイル: Main.py プロジェクト: ssj018/maxent
def run(season, seasonType, dataFile):
    # list that contains the original data
    #raw = []

    # get label and home/road
    s = StatsView(leagueId, opponentTeamId, season, seasonType, teamId)
    if s.doRequest():
        print "Cant get label and home/road"
    else:
        #print s.getLabelVsLocation()
        pass

    # get current league ranking
    c = CurrentLeagueRanking(season, seasonType, leagueId, teamId)
    if c.doRequest():
        print "Cant get current league ranking"
    else:
        #print c.getCurrentLeagueRanking()
        pass

    # get average age height weight
    t = TeamProfile(season, leagueId, teamId)
    if t.doRequest():
        print "Cant get AVGS of age height weight"
    else:
        #print t.getAVGs()
        pass

    # get player stats in total
    p = PlayerHelper(teamId, season, seasonType, leagueId)
    p.fillCurrentSeasonStats()
    #print p.getCurrentSeasonStatsInTotals()

    # fill the raw
    for item in s.getLabelVsLocation():
        raw = []
        raw.append(season)
        raw.append(item[1])
        raw.append("null")
        raw.append(c.getCurrentLeagueRanking()[0])
        raw.append(c.getCurrentLeagueRanking()[1])
        raw.append(c.getCurrentLeagueRanking()[2])
        raw.append(c.getCurrentLeagueRanking()[3])
        raw.append("null")
        raw.append(item[0])
        raw.append(t.getAVGs()[0])
        raw.append(t.getAVGs()[1])
        raw.append(t.getAVGs()[2])
        raw.append(p.getCurrentSeasonStatsInTotals()[0])
        raw.append(p.getCurrentSeasonStatsInTotals()[1])
        raw.append(p.getCurrentSeasonStatsInTotals()[2])
        raw.append(p.getCurrentSeasonStatsInTotals()[3])
        raw.append("null")
        raw.append("null")
        raw.append("null")
        appendlst2file(raw, dataFile)
コード例 #2
0
ファイル: Main.py プロジェクト: csrgxtu/maxent
def run(season, seasonType, dataFile):
  # list that contains the original data
  #raw = []
  
  # get label and home/road
  s = StatsView(leagueId, opponentTeamId, season, seasonType, teamId)
  if s.doRequest():
    print "Cant get label and home/road"
  else:
    #print s.getLabelVsLocation()
    pass
  
  # get current league ranking
  c = CurrentLeagueRanking(season, seasonType, leagueId, teamId)
  if c.doRequest():
    print "Cant get current league ranking"
  else:
    #print c.getCurrentLeagueRanking()
    pass
  
  # get average age height weight
  t = TeamProfile(season, leagueId, teamId)
  if t.doRequest():
    print "Cant get AVGS of age height weight"
  else:
    #print t.getAVGs()
    pass
  
  # get player stats in total
  p = PlayerHelper(teamId, season, seasonType, leagueId)
  p.fillCurrentSeasonStats()
  #print p.getCurrentSeasonStatsInTotals()
  
  # fill the raw
  for item in s.getLabelVsLocation():
    raw = []
    raw.append(season)
    raw.append(item[1])
    raw.append("null")
    raw.append(c.getCurrentLeagueRanking()[0])
    raw.append(c.getCurrentLeagueRanking()[1])
    raw.append(c.getCurrentLeagueRanking()[2])
    raw.append(c.getCurrentLeagueRanking()[3])
    raw.append("null")
    raw.append(item[0])
    raw.append(t.getAVGs()[0])
    raw.append(t.getAVGs()[1])
    raw.append(t.getAVGs()[2])
    raw.append(p.getCurrentSeasonStatsInTotals()[0])
    raw.append(p.getCurrentSeasonStatsInTotals()[1])
    raw.append(p.getCurrentSeasonStatsInTotals()[2])
    raw.append(p.getCurrentSeasonStatsInTotals()[3])
    raw.append("null")
    raw.append("null")
    raw.append("null")
    appendlst2file(raw, dataFile)
コード例 #3
0
ファイル: KNearestGames.py プロジェクト: ssj018/maxent
 def prepareRecords(self, teamida, teamidb):
   for i in range(len(self.teamLst) - self.k + 1):
     print "Prepare " + str(i) + "th record"
     lsta = self.teamLst[i:i+self.k]
     lstb = self.opponentTeamLst[i:i+self.k]
     lstaa = self.selectColumns(lsta, teamida)
     lstbb = self.selectColumns(lstb, teamidb)
     # print "Debug: "
     # print lstb
     appendlst2file(self.prepareRecord(lstaa, lstbb), self.outputFile)
コード例 #4
0
def run(teamId, season, seasonType, leagueId, dataFile):
  t = NBAStatsExtractor(teamId, season, seasonType, leagueId)
  # print t.getCurrentLeagueRankingInfo()
  # print t.getTeamProfileInfo()
  # print t.getTechStatsInfo()

  ranking = t.getCurrentLeagueRankingInfo()
  profile = t.getTeamProfileInfo()
  for item in t.getTechStatsInfo()['stats']:
    tmpLst = []
    tmpLst.append(item['WIN'])
    tmpLst.append(item['DATE'])

    tmpLst.append(season)
    tmpLst.append(seasonType)
    tmpLst.append(leagueId)

    tmpLst.append(item['MATCHUP'])
    tmpLst.append(item['FGM'])
    tmpLst.append(item['FGA'])
    tmpLst.append(item['FG3M'])
    tmpLst.append(item['FG3A'])
    tmpLst.append(item['FTM'])
    tmpLst.append(item['FTA'])
    tmpLst.append(item['OREB'])
    tmpLst.append(item['DREB'])
    tmpLst.append(item['AST'])
    tmpLst.append(item['STL'])
    tmpLst.append(item['BLK'])
    tmpLst.append(item['TOV'])
    tmpLst.append(item['PF'])
    tmpLst.append(item['PTS'])

    tmpLst.append(ranking['PPG'])
    tmpLst.append(ranking['RPG'])
    tmpLst.append(ranking['APG'])
    tmpLst.append(ranking['OPPG'])

    tmpLst.append(profile['Height'])
    tmpLst.append(profile['Weight'])
    tmpLst.append(profile['Age'])

    appendlst2file(tmpLst, dataFile)
コード例 #5
0
#!/usr/bin/env python
# coding = utf-8
# Author: Archer Reilly
# Date: 21/Nov/2014
# File: BatchGenerateLeagueRank.py
# Desc: use LeagueRank batch generate the league rank for each .m
# file in the data dir
#
# Produced By CSRGXTU
from LeagueRank import LeagueRank
from Utility import loadMatrixFromFile, readmatricefromfile, appendlst2file

DATA_PATH = '/home/archer/Documents/maxent/data/basketball/leaguerank/'
DATES_FILE = DATA_PATH + 'dates.csv'
L = [1/float(30) for e in range(1, 31)]

dates = loadMatrixFromFile(DATES_FILE)[0]

for d  in dates[3633:]:
  print 'INFO: generate LeagueRank for ' + d + '.m'
  #o = LeagueRank(L, readmatricefromfile(DATA_PATH + d + '.m'), 0.00000001, 100000)
  o = LeagueRank(L, readmatricefromfile(DATA_PATH + d + '.m'), 0.001, 10)
  # print 'Debug: ',
  # print o.rank()
  appendlst2file(o.rank(), DATA_PATH + d + '.l')
  print '    Done'
  # break
コード例 #6
0
ファイル: TeamTechStatsMain.py プロジェクト: ssj018/maxent
def run(season, seasonType, dataFile):
    t = TeamTechStatsExtractor(teamId, opponentTeamId, season, seasonType,
                               leagueId)
    vst = TeamTechStatsExtractor(opponentTeamId, teamId, season, seasonType,
                                 leagueId)
    tRank = t.getCurrentLeagueRankingInfo()
    tTech = t.getTechStatsInfo()
    tProfile = t.getTeamProfileInfo()
    vstRank = vst.getCurrentLeagueRankingInfo()
    vstTech = vst.getTechStatsInfo()
    vstProfile = vst.getTeamProfileInfo()

    raw = []
    # label
    raw.append(tTech['Home']['Win'])

    raw.append(tRank['PPG'])
    raw.append(tRank['RPG'])
    raw.append(tRank['APG'])
    raw.append(tRank['OPPG'])

    raw.append(vstRank['PPG'])
    raw.append(vstRank['RPG'])
    raw.append(vstRank['APG'])
    raw.append(vstRank['OPPG'])

    raw.append(tProfile['Height'])
    raw.append(tProfile['Weight'])
    raw.append(tProfile['Age'])

    raw.append(vstProfile['Height'])
    raw.append(vstProfile['Weight'])
    raw.append(vstProfile['Age'])

    #raw.append(tTech['Home']['Location'])
    if tTech['Home']['Location'] == 'Home':
        raw.append(1)
    else:
        raw.append(0)

    raw.append(tTech['Home']['FGM'])
    raw.append(tTech['Home']['FGA'])
    raw.append(tTech['Home']['FG3M'])
    raw.append(tTech['Home']['FG3A'])
    raw.append(tTech['Home']['FTM'])
    raw.append(tTech['Home']['FTA'])
    raw.append(tTech['Home']['OREB'])
    raw.append(tTech['Home']['DREB'])
    raw.append(tTech['Home']['AST'])
    raw.append(tTech['Home']['TOV'])
    raw.append(tTech['Home']['STL'])
    raw.append(tTech['Home']['BLK'])
    raw.append(tTech['Home']['BLKA'])
    raw.append(tTech['Home']['PF'])
    raw.append(tTech['Home']['PTS'])
    raw.append(tTech['Home']['PLUS-MINUS'])

    #raw.append(vstTech['Road']['Location'])
    if vstTech['Road']['Location'] == 'Home':
        raw.append(1)
    else:
        raw.append(0)

    raw.append(vstTech['Road']['FGM'])
    raw.append(vstTech['Road']['FGA'])
    raw.append(vstTech['Road']['FG3M'])
    raw.append(vstTech['Road']['FG3A'])
    raw.append(vstTech['Road']['FTM'])
    raw.append(vstTech['Road']['FTA'])
    raw.append(vstTech['Road']['OREB'])
    raw.append(vstTech['Road']['DREB'])
    raw.append(vstTech['Road']['AST'])
    raw.append(vstTech['Road']['TOV'])
    raw.append(vstTech['Road']['STL'])
    raw.append(vstTech['Road']['BLK'])
    raw.append(vstTech['Road']['BLKA'])
    raw.append(vstTech['Road']['PF'])
    raw.append(vstTech['Road']['PTS'])
    raw.append(vstTech['Road']['PLUS-MINUS'])

    appendlst2file(raw, dataFile)

    raw = []
    # label
    raw.append(tTech['Road']['Win'])

    raw.append(tRank['PPG'])
    raw.append(tRank['RPG'])
    raw.append(tRank['APG'])
    raw.append(tRank['OPPG'])

    raw.append(vstRank['PPG'])
    raw.append(vstRank['RPG'])
    raw.append(vstRank['APG'])
    raw.append(vstRank['OPPG'])

    raw.append(tProfile['Height'])
    raw.append(tProfile['Weight'])
    raw.append(tProfile['Age'])

    raw.append(vstProfile['Height'])
    raw.append(vstProfile['Weight'])
    raw.append(vstProfile['Age'])

    #raw.append(tTech['Road']['Location'])
    if tTech['Road']['Location'] == 'Home':
        raw.append(1)
    else:
        raw.append(0)

    raw.append(tTech['Road']['FGM'])
    raw.append(tTech['Road']['FGA'])
    raw.append(tTech['Road']['FG3M'])
    raw.append(tTech['Road']['FG3A'])
    raw.append(tTech['Road']['FTM'])
    raw.append(tTech['Road']['FTA'])
    raw.append(tTech['Road']['OREB'])
    raw.append(tTech['Road']['DREB'])
    raw.append(tTech['Road']['AST'])
    raw.append(tTech['Road']['TOV'])
    raw.append(tTech['Road']['STL'])
    raw.append(tTech['Road']['BLK'])
    raw.append(tTech['Road']['BLKA'])
    raw.append(tTech['Road']['PF'])
    raw.append(tTech['Road']['PTS'])
    raw.append(tTech['Road']['PLUS-MINUS'])

    #raw.append(vstTech['Home']['Location'])
    if vstTech['Home']['Location'] == 'Home':
        raw.append(1)
    else:
        raw.append(0)

    raw.append(vstTech['Home']['FGM'])
    raw.append(vstTech['Home']['FGA'])
    raw.append(vstTech['Home']['FG3M'])
    raw.append(vstTech['Home']['FG3A'])
    raw.append(vstTech['Home']['FTM'])
    raw.append(vstTech['Home']['FTA'])
    raw.append(vstTech['Home']['OREB'])
    raw.append(vstTech['Home']['DREB'])
    raw.append(vstTech['Home']['AST'])
    raw.append(vstTech['Home']['TOV'])
    raw.append(vstTech['Home']['STL'])
    raw.append(vstTech['Home']['BLK'])
    raw.append(vstTech['Home']['BLKA'])
    raw.append(vstTech['Home']['PF'])
    raw.append(vstTech['Home']['PTS'])
    raw.append(vstTech['Home']['PLUS-MINUS'])

    appendlst2file(raw, dataFile)
コード例 #7
0
    print '   INFO: load martix from ' + sortedFiles[i]
    tmpMatrix = loadMatrixFromFile('/home/archer/Documents/maxent/data/basketball/leaguerank/' + sortedFiles[i])
    tmpMatrixa = []
    """
    for row in tmpMatrix:
      if row[1] == d:
        tmpMatrixa.append(row)
        break
      else:
        tmpMatrixa.append(row)
    """
    for row in tmpMatrix:
      if row[1] == d:
        # print '   DEBUG: ',
        # print row
        appendlst2file(row, '/home/archer/Documents/maxent/data/basketball/leaguerank/' + sortedFiles[i] + '.swp')

    # print '   DEBUG generateRow:',
    tmpMatrixb.append(generateRow(loadMatrixFromFile('/home/archer/Documents/maxent/data/basketball/leaguerank/' + sortedFiles[i] + '.swp'), sortedNames[i]))
    # appendlst2file(tmpMatrixa, '/home/archer/Documents/maxent/data/basketball/leaguerank/' + sortedFiles[i] + '.swp')
    # tmpMatrixb.append(generateRow(loadMatrixFromFile('/home/archer/Documents/maxent/data/basketball/leaguerank/' + sortedFiles[i] + '.swp'), sortedNames[i]))
    # break
  # print 'INFO: matrix for ' + d + ':'
  # print tmpMatrixb
  # print 'INFO: save ' + d + '.m  Done'
  # print '\033[1;31mINFO: save %s.m  Done\t\t\033[1;m' % d
  print '\033[1;32mINFO: save %s.m  Done\t\tON\033[1;m' % d
  saveMatrixToFile('/home/archer/Documents/maxent/data/basketball/leaguerank/' + d + '.m', tmpMatrixb)
  # break

コード例 #8
0
ファイル: TeamTechStatsMain.py プロジェクト: csrgxtu/maxent
def run(season, seasonType, dataFile):
  t = TeamTechStatsExtractor(teamId, opponentTeamId, season, seasonType, leagueId)
  vst = TeamTechStatsExtractor(opponentTeamId, teamId, season, seasonType, leagueId)
  tRank = t.getCurrentLeagueRankingInfo()
  tTech = t.getTechStatsInfo()
  tProfile = t.getTeamProfileInfo()
  vstRank = vst.getCurrentLeagueRankingInfo()
  vstTech = vst.getTechStatsInfo()
  vstProfile = vst.getTeamProfileInfo()

  raw = []
  # label
  raw.append(tTech['Home']['Win'])

  raw.append(tRank['PPG'])
  raw.append(tRank['RPG'])
  raw.append(tRank['APG'])
  raw.append(tRank['OPPG'])

  raw.append(vstRank['PPG'])
  raw.append(vstRank['RPG'])
  raw.append(vstRank['APG'])
  raw.append(vstRank['OPPG'])

  raw.append(tProfile['Height'])
  raw.append(tProfile['Weight'])
  raw.append(tProfile['Age'])

  raw.append(vstProfile['Height'])
  raw.append(vstProfile['Weight'])
  raw.append(vstProfile['Age'])

  #raw.append(tTech['Home']['Location'])
  if tTech['Home']['Location'] == 'Home':
    raw.append(1)
  else:
    raw.append(0)

  raw.append(tTech['Home']['FGM'])
  raw.append(tTech['Home']['FGA'])
  raw.append(tTech['Home']['FG3M'])
  raw.append(tTech['Home']['FG3A'])
  raw.append(tTech['Home']['FTM'])
  raw.append(tTech['Home']['FTA'])
  raw.append(tTech['Home']['OREB'])
  raw.append(tTech['Home']['DREB'])
  raw.append(tTech['Home']['AST'])
  raw.append(tTech['Home']['TOV'])
  raw.append(tTech['Home']['STL'])
  raw.append(tTech['Home']['BLK'])
  raw.append(tTech['Home']['BLKA'])
  raw.append(tTech['Home']['PF'])
  raw.append(tTech['Home']['PTS'])
  raw.append(tTech['Home']['PLUS-MINUS'])

  #raw.append(vstTech['Road']['Location'])
  if vstTech['Road']['Location'] == 'Home':
    raw.append(1)
  else:
    raw.append(0)

  raw.append(vstTech['Road']['FGM'])
  raw.append(vstTech['Road']['FGA'])
  raw.append(vstTech['Road']['FG3M'])
  raw.append(vstTech['Road']['FG3A'])
  raw.append(vstTech['Road']['FTM'])
  raw.append(vstTech['Road']['FTA'])
  raw.append(vstTech['Road']['OREB'])
  raw.append(vstTech['Road']['DREB'])
  raw.append(vstTech['Road']['AST'])
  raw.append(vstTech['Road']['TOV'])
  raw.append(vstTech['Road']['STL'])
  raw.append(vstTech['Road']['BLK'])
  raw.append(vstTech['Road']['BLKA'])
  raw.append(vstTech['Road']['PF'])
  raw.append(vstTech['Road']['PTS'])
  raw.append(vstTech['Road']['PLUS-MINUS'])

  appendlst2file(raw, dataFile)

  raw = []
  # label
  raw.append(tTech['Road']['Win'])

  raw.append(tRank['PPG'])
  raw.append(tRank['RPG'])
  raw.append(tRank['APG'])
  raw.append(tRank['OPPG'])

  raw.append(vstRank['PPG'])
  raw.append(vstRank['RPG'])
  raw.append(vstRank['APG'])
  raw.append(vstRank['OPPG'])

  raw.append(tProfile['Height'])
  raw.append(tProfile['Weight'])
  raw.append(tProfile['Age'])

  raw.append(vstProfile['Height'])
  raw.append(vstProfile['Weight'])
  raw.append(vstProfile['Age'])

  #raw.append(tTech['Road']['Location'])
  if tTech['Road']['Location'] == 'Home':
    raw.append(1)
  else:
    raw.append(0)

  raw.append(tTech['Road']['FGM'])
  raw.append(tTech['Road']['FGA'])
  raw.append(tTech['Road']['FG3M'])
  raw.append(tTech['Road']['FG3A'])
  raw.append(tTech['Road']['FTM'])
  raw.append(tTech['Road']['FTA'])
  raw.append(tTech['Road']['OREB'])
  raw.append(tTech['Road']['DREB'])
  raw.append(tTech['Road']['AST'])
  raw.append(tTech['Road']['TOV'])
  raw.append(tTech['Road']['STL'])
  raw.append(tTech['Road']['BLK'])
  raw.append(tTech['Road']['BLKA'])
  raw.append(tTech['Road']['PF'])
  raw.append(tTech['Road']['PTS'])
  raw.append(tTech['Road']['PLUS-MINUS'])

  #raw.append(vstTech['Home']['Location'])
  if vstTech['Home']['Location'] == 'Home':
    raw.append(1)
  else:
    raw.append(0)

  raw.append(vstTech['Home']['FGM'])
  raw.append(vstTech['Home']['FGA'])
  raw.append(vstTech['Home']['FG3M'])
  raw.append(vstTech['Home']['FG3A'])
  raw.append(vstTech['Home']['FTM'])
  raw.append(vstTech['Home']['FTA'])
  raw.append(vstTech['Home']['OREB'])
  raw.append(vstTech['Home']['DREB'])
  raw.append(vstTech['Home']['AST'])
  raw.append(vstTech['Home']['TOV'])
  raw.append(vstTech['Home']['STL'])
  raw.append(vstTech['Home']['BLK'])
  raw.append(vstTech['Home']['BLKA'])
  raw.append(vstTech['Home']['PF'])
  raw.append(vstTech['Home']['PTS'])
  raw.append(vstTech['Home']['PLUS-MINUS'])

  appendlst2file(raw, dataFile)
コード例 #9
0
#!/usr/bin/env python
# coding = utf-8
# Author: Archer Reilly
# Date: 21/Nov/2014
# File: BatchGenerateLeagueRank.py
# Desc: use LeagueRank batch generate the league rank for each .m
# file in the data dir
#
# Produced By CSRGXTU
from LeagueRank import LeagueRank
from Utility import loadMatrixFromFile, readmatricefromfile, appendlst2file

DATA_PATH = '/home/archer/Documents/maxent/data/basketball/leaguerank/'
DATES_FILE = DATA_PATH + 'dates.csv'
L = [1 / float(30) for e in range(1, 31)]

dates = loadMatrixFromFile(DATES_FILE)[0]

for d in dates[3633:]:
    print 'INFO: generate LeagueRank for ' + d + '.m'
    #o = LeagueRank(L, readmatricefromfile(DATA_PATH + d + '.m'), 0.00000001, 100000)
    o = LeagueRank(L, readmatricefromfile(DATA_PATH + d + '.m'), 0.001, 10)
    # print 'Debug: ',
    # print o.rank()
    appendlst2file(o.rank(), DATA_PATH + d + '.l')
    print '    Done'
    # break