patrickramos commited on
Commit
20e5dad
·
1 Parent(s): 64eeaff

Fix bug prevent sweepers from being recognized

Browse files
Files changed (3) hide show
  1. convert.py +13 -6
  2. data/data.py +6 -6
  3. grade.py +2 -1
convert.py CHANGED
@@ -47,7 +47,8 @@ ball_kind = {
47
  50: 'Eephus', # technically "super" eephus but I haven't encountered a normal one yet
48
  51: 'Hard Sinker',
49
  52: 'Hard Slider',
50
- 53: 'Sinker-Change' # custom class for changeups that are classified as sinekrs
 
51
  }
52
 
53
  ball_kind_code = {
@@ -74,7 +75,8 @@ ball_kind_code = {
74
  50: 'EP', # technically "super" eephus but I haven't encountered a normal one yet
75
  51: 'HS',
76
  52: 'HL',
77
- 53: 'SG' # custom class for changeups that are classified as sinekrs
 
78
  }
79
 
80
  general_ball_kind = {
@@ -101,7 +103,8 @@ general_ball_kind = {
101
  50: 'Eephus', # technically "super" eephus but I haven't encountered a normal one yet
102
  51: 'Sinker',
103
  52: 'Vertical Slider',
104
- 53: 'Changeup'
 
105
  }
106
 
107
  general_ball_kind_code = {
@@ -128,7 +131,8 @@ general_ball_kind_code = {
128
  50: 'EP', # technically "super" eephus but I haven't encountered a normal one yet
129
  51: 'SI',
130
  52: 'VS',
131
- 53: 'CH'
 
132
  }
133
 
134
  basic_ball_kind = {
@@ -155,7 +159,8 @@ basic_ball_kind = {
155
  50: 'Off-speed', # technically "super" eephus but I haven't encountered a normal one yet
156
  51: 'Fastball',
157
  52: 'Breaking',
158
- 53: 'Off-speed',
 
159
  }
160
 
161
  basic_ball_kind_code = {
@@ -182,7 +187,8 @@ basic_ball_kind_code = {
182
  50: 'OS', # technically "super" eephus but I haven't encountered a normal one yet
183
  51: 'FB',
184
  52: 'BR',
185
- 53: 'OS'
 
186
  }
187
 
188
  verify_and_return_basic_ball_kind_code = create_verify_and_return_fn(basic_ball_kind_code.values())
@@ -408,6 +414,7 @@ ball_kind_code_to_color = {
408
  'EP': 'darkgray', # technically "super" eephus but I haven't encountered a normal one yet
409
  'HS': 'darkorange',
410
  'HL': 'darkkhaki',
 
411
  'SG': 'olive'
412
  }
413
 
 
47
  50: 'Eephus', # technically "super" eephus but I haven't encountered a normal one yet
48
  51: 'Hard Sinker',
49
  52: 'Hard Slider',
50
+ 53: 'Sweeper',
51
+ 54: 'Sinker-Change' # custom class for changeups that are classified as sinekrs
52
  }
53
 
54
  ball_kind_code = {
 
75
  50: 'EP', # technically "super" eephus but I haven't encountered a normal one yet
76
  51: 'HS',
77
  52: 'HL',
78
+ 53: 'ST',
79
+ 54: 'SG' # custom class for changeups that are classified as sinkers
80
  }
81
 
82
  general_ball_kind = {
 
103
  50: 'Eephus', # technically "super" eephus but I haven't encountered a normal one yet
104
  51: 'Sinker',
105
  52: 'Vertical Slider',
106
+ 53: 'Sweeper',
107
+ 54: 'Changeup'
108
  }
109
 
110
  general_ball_kind_code = {
 
131
  50: 'EP', # technically "super" eephus but I haven't encountered a normal one yet
132
  51: 'SI',
133
  52: 'VS',
134
+ 53: 'ST',
135
+ 54: 'CH'
136
  }
137
 
138
  basic_ball_kind = {
 
159
  50: 'Off-speed', # technically "super" eephus but I haven't encountered a normal one yet
160
  51: 'Fastball',
161
  52: 'Breaking',
162
+ 53: 'Breaking',
163
+ 54: 'Off-speed',
164
  }
165
 
166
  basic_ball_kind_code = {
 
187
  50: 'OS', # technically "super" eephus but I haven't encountered a normal one yet
188
  51: 'FB',
189
  52: 'BR',
190
+ 53: 'BR',
191
+ 54: 'OS'
192
  }
193
 
194
  verify_and_return_basic_ball_kind_code = create_verify_and_return_fn(basic_ball_kind_code.values())
 
414
  'EP': 'darkgray', # technically "super" eephus but I haven't encountered a normal one yet
415
  'HS': 'darkorange',
416
  'HL': 'darkkhaki',
417
+ 'ST': 'goldenrod',
418
  'SG': 'olive'
419
  }
420
 
data/data.py CHANGED
@@ -321,12 +321,12 @@ data_df = (
321
  .alias('replace_sinker'),
322
  )
323
  .with_columns(
324
- pl.when('replace_sinker').then(pl.lit(ball_kind[53])).otherwise('ballKind').alias('ballKind'),
325
- pl.when('replace_sinker').then(pl.lit(ball_kind_code[53])).otherwise('ballKind_code').alias('ballKind_code'),
326
- pl.when('replace_sinker').then(pl.lit(general_ball_kind[53])).otherwise('general_ballKind').alias('general_ballKind'),
327
- pl.when('replace_sinker').then(pl.lit(general_ball_kind_code[53])).otherwise('general_ballKind_code').alias('general_ballKind_code'),
328
- pl.when('replace_sinker').then(pl.lit(basic_ball_kind[53])).otherwise('basic_ballKind').alias('basic_ballKind'),
329
- pl.when('replace_sinker').then(pl.lit(basic_ball_kind_code[53])).otherwise('basic_ballKind_code').alias('basic_ballKind_code'),
330
  )
331
  .drop('replace_sinker')
332
 
 
321
  .alias('replace_sinker'),
322
  )
323
  .with_columns(
324
+ pl.when('replace_sinker').then(pl.lit(ball_kind[54])).otherwise('ballKind').alias('ballKind'),
325
+ pl.when('replace_sinker').then(pl.lit(ball_kind_code[54])).otherwise('ballKind_code').alias('ballKind_code'),
326
+ pl.when('replace_sinker').then(pl.lit(general_ball_kind[54])).otherwise('general_ballKind').alias('general_ballKind'),
327
+ pl.when('replace_sinker').then(pl.lit(general_ball_kind_code[54])).otherwise('general_ballKind_code').alias('general_ballKind_code'),
328
+ pl.when('replace_sinker').then(pl.lit(basic_ball_kind[54])).otherwise('basic_ballKind').alias('basic_ballKind'),
329
+ pl.when('replace_sinker').then(pl.lit(basic_ball_kind_code[54])).otherwise('basic_ballKind_code').alias('basic_ballKind_code'),
330
  )
331
  .drop('replace_sinker')
332
 
grade.py CHANGED
@@ -27,7 +27,8 @@ pera_ball_kind = {
27
  'Screwball': 'Curve',
28
  'Slurve': 'Curve',
29
  'Eephus': 'Curve',
30
- 'Knuckleball': 'Curve'
 
31
  }
32
 
33
  pera_ball_kind_col = pl.col('general_ballKind').replace_strict(pera_ball_kind).alias('YpERA Pitch')
 
27
  'Screwball': 'Curve',
28
  'Slurve': 'Curve',
29
  'Eephus': 'Curve',
30
+ 'Knuckleball': 'Curve',
31
+ 'Sweeper': 'Slider'
32
  }
33
 
34
  pera_ball_kind_col = pl.col('general_ballKind').replace_strict(pera_ball_kind).alias('YpERA Pitch')