dcayton commited on
Commit
a0d8c4f
1 Parent(s): e5d9cc0

attempting to implement configs so that I can change loads

Browse files
Files changed (1) hide show
  1. nba_tracking_data_15_16.py +37 -9
nba_tracking_data_15_16.py CHANGED
@@ -47,14 +47,6 @@ res = requests.get(_URL)
47
 
48
  items = res.json()['payload']['tree']['items']
49
 
50
- random.seed()
51
- items = random.sample(items, 50)
52
-
53
- _URLS = {}
54
- for game in items:
55
- name = game['name'][:-3]
56
- _URLS[name] = _URL + "/" + name + ".7z"
57
-
58
  def home_away_event_conversion(number):
59
  if pd.isna(number.item()):
60
  return None
@@ -76,10 +68,46 @@ def identify_offense(row):
76
  else:
77
  poss_team_id = None
78
  return poss_team_id
79
-
 
 
 
 
 
 
 
80
  class NbaTracking(datasets.GeneratorBasedBuilder):
81
  """Tracking data for all games of 2015-2016 season in forms of coordinates for players and ball at each moment."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
 
 
 
 
 
83
  _URLS = _URLS
84
  _PBP_URL = _PBP_URL
85
 
 
47
 
48
  items = res.json()['payload']['tree']['items']
49
 
 
 
 
 
 
 
 
 
50
  def home_away_event_conversion(number):
51
  if pd.isna(number.item()):
52
  return None
 
68
  else:
69
  poss_team_id = None
70
  return poss_team_id
71
+
72
+ class NbaTrackingConfig(datasets.BuilderConfig):
73
+ """BuilderConfig for NbaTracking"""
74
+
75
+ def __init__(self, samples):
76
+ super(NbaTrackingConfig, self).__init__(**kwargs)
77
+ self.samples = samples
78
+
79
  class NbaTracking(datasets.GeneratorBasedBuilder):
80
  """Tracking data for all games of 2015-2016 season in forms of coordinates for players and ball at each moment."""
81
+
82
+ BUILDER_CONFIG_CLASS = NbaTrackingConfig
83
+
84
+ BUILDER_CONFIGS = [
85
+ NbaTrackingConfig(
86
+ name = "tiny",
87
+ samples = 5
88
+ ),
89
+ NbaTrackingConfig(
90
+ name = "small",
91
+ samples = 25
92
+ ),
93
+ NbaTrackingConfig(
94
+ name = "medium",
95
+ samples = 100
96
+ ),
97
+ NbaTrackingConfig(
98
+ name = "full",
99
+ samples = len(items)
100
+ )
101
+ ]
102
+
103
+ random.seed(9)
104
+ items = random.sample(items, self.config.samples)
105
 
106
+ _URLS = {}
107
+ for game in items:
108
+ name = game['name'][:-3]
109
+ _URLS[name] = _URL + "/" + name + ".7z"
110
+
111
  _URLS = _URLS
112
  _PBP_URL = _PBP_URL
113