-
Notifications
You must be signed in to change notification settings - Fork 0
/
teamStatGraph.py
77 lines (56 loc) · 3.05 KB
/
teamStatGraph.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
## teamStatGraph.py ############################################################
## create a graph of two parameters specified and save it to the results #######
## folder ######################################################################
################################################################################
from sys import argv
from scrapParam import *
import statSelect
def moduleId():
return "teamStatGraph"
def description():
output = "The teamStatGraph module is used to create an on-demand graph of a given\n"
output += "pair of stats for the range of seasons &/or teams specified\n"
return output
def exampleCommand():
output = "python teamStatGraph.py nhl everything True PGDT CPQI*GDA\n"
output += "(where PGDT is dependent, CPQI*GDA is independent)"
return output
def task(seasons, parameters):
seasons = filterSeasonsByParams(seasons, parameters)
parameters.info()
if(parameters.getPlayoffTeamsOnly()):
thing = 'PlayoffTeam'
else:
thing = 'Total'
independent = statSelect.getTargetStatContainer(parameters.getIndependentStatName(), seasons, parameters.getLeagueId(), parameters.getLevelId())
print "Independent"
independent.printStatBounds()
dependent = statSelect.getTargetStatContainer(parameters.getTargetStatName(), seasons, parameters.getLeagueId(), parameters.getLevelId())
print "Dependent"
dependent.printStatBounds()
for var in [independent, dependent]:
plotHistogram(var.getShortStatName(), 'Count', 'Histogram of %s' % var.getLongStatName(), var.getStat(parameters.getPlayoffTeamsOnly()),'./results/%s/%s/histograms' % (parameters.getLeagueId(), parameters.getLevelId()), '%s' % var.getShortStatName(), '%s_%s_histogram.png' % (var.getShortStatName(), thing))
plotScatterplot(independent.getShortStatName(), dependent.getShortStatName(), '%s\nby %s\nfor %s, %s' % (dependent.getLongStatName(), independent.getLongStatName(), parameters.getLeagueId(), parameters.getLevelId()), independent.getStat(parameters.getPlayoffTeamsOnly()), dependent.getStat(parameters.getPlayoffTeamsOnly()), './results/%s/%s/%sBy' % (parameters.getLeagueId(), parameters.getLevelId(), dependent.getShortStatName()), '%s' % independent.getShortStatName(), '%s_by_%s.png' % (dependent.getShortStatName(), independent.getShortStatName()))
if(__name__ == "__main__"):
try:
leagueId = argv[1]
## ie 'watMu'
levelId = argv[2]
## ie 'beginner'
dependentStat = argv[4]
independentStat = argv[5]
playoffTeamsOnly = argv[3]
if(playoffTeamsOnly == "True"):
playoffTeamsOnly = True
elif(playoffTeamsOnly == "False"):
playoffTeamsOnly = False
else:
print "Unable to parse third option 'playoffTeamsOnly' provided as %s" % playoffTeamsOnly
raise IndexError
except IndexError:
print "Arguments %s failing due to index error, see example commands for %s:\n" % (tuple(argv[1:]), argv[0])
print exampleCommand()
exit()
seasons = getAllSeasons(leagueId, levelId)
parameters = scrapParams(leagueId, levelId, playoffTeamsOnly, [], [], "Linear", dependentStat, independentStatName=independentStat)
task(seasons, parameters)