Spaces:
Running
Running
Commit
·
c775359
1
Parent(s):
aea1a40
Choose OFFB implementation of HR/FB
Browse files- pitch_leaderboard.py +2 -2
- player_team_leaderboard.py +2 -2
- stats.py +3 -2
pitch_leaderboard.py
CHANGED
|
@@ -41,7 +41,7 @@ def create_pitch_leaderboard(player_team_type):
|
|
| 41 |
prefix_cols = [col for col in prefix_cols if col not in ('Pitcher', 'Throws')]
|
| 42 |
theme_to_cols = {
|
| 43 |
'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'Strike%', 'Ball%', 'F-Str%', 'PAR%', 'PLUS%'],
|
| 44 |
-
'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR/FB'
|
| 45 |
'Approach': ['Zone%', 'Arm%', 'Glove%', 'High%', 'Low%', 'MM%', 'Behind%']
|
| 46 |
}
|
| 47 |
|
|
@@ -51,7 +51,7 @@ def create_pitch_leaderboard(player_team_type):
|
|
| 51 |
prefix_cols = [col for col in prefix_cols if col not in ('Batter', 'Bats')]
|
| 52 |
theme_to_cols = {
|
| 53 |
'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'PLUS%'],
|
| 54 |
-
'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR/FB'
|
| 55 |
}
|
| 56 |
|
| 57 |
all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
|
|
|
|
| 41 |
prefix_cols = [col for col in prefix_cols if col not in ('Pitcher', 'Throws')]
|
| 42 |
theme_to_cols = {
|
| 43 |
'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'Strike%', 'Ball%', 'F-Str%', 'PAR%', 'PLUS%'],
|
| 44 |
+
'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR/FB'],
|
| 45 |
'Approach': ['Zone%', 'Arm%', 'Glove%', 'High%', 'Low%', 'MM%', 'Behind%']
|
| 46 |
}
|
| 47 |
|
|
|
|
| 51 |
prefix_cols = [col for col in prefix_cols if col not in ('Batter', 'Bats')]
|
| 52 |
theme_to_cols = {
|
| 53 |
'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'PLUS%'],
|
| 54 |
+
'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR/FB']
|
| 55 |
}
|
| 56 |
|
| 57 |
all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
|
player_team_leaderboard.py
CHANGED
|
@@ -33,7 +33,7 @@ def create_player_team_leaderboard_app(player_team_type):
|
|
| 33 |
prefix_cols = [col for col in prefix_cols if col not in ('Pitcher', 'Throws')]
|
| 34 |
theme_to_cols = {
|
| 35 |
'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'Strike%', 'Ball%', 'F-Str%', 'PAR%', 'PLUS%'],
|
| 36 |
-
'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR%', 'HR/FB'
|
| 37 |
'Approach': ['Zone%', 'Arm%', 'Glove%', 'High%', 'Low%', 'MM%', 'Behind%', 'Sec%']
|
| 38 |
}
|
| 39 |
all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
|
|
@@ -46,7 +46,7 @@ def create_player_team_leaderboard_app(player_team_type):
|
|
| 46 |
prefix_cols = [col for col in prefix_cols if col not in ('Batter', 'Bats')]
|
| 47 |
theme_to_cols = {
|
| 48 |
'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'PLUS%'],
|
| 49 |
-
'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR%', 'HR/FB'
|
| 50 |
}
|
| 51 |
all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
|
| 52 |
for theme, cols in theme_to_cols.items():
|
|
|
|
| 33 |
prefix_cols = [col for col in prefix_cols if col not in ('Pitcher', 'Throws')]
|
| 34 |
theme_to_cols = {
|
| 35 |
'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'Strike%', 'Ball%', 'F-Str%', 'PAR%', 'PLUS%'],
|
| 36 |
+
'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR%', 'HR/FB'],
|
| 37 |
'Approach': ['Zone%', 'Arm%', 'Glove%', 'High%', 'Low%', 'MM%', 'Behind%', 'Sec%']
|
| 38 |
}
|
| 39 |
all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
|
|
|
|
| 46 |
prefix_cols = [col for col in prefix_cols if col not in ('Batter', 'Bats')]
|
| 47 |
theme_to_cols = {
|
| 48 |
'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'PLUS%'],
|
| 49 |
+
'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR%', 'HR/FB']
|
| 50 |
}
|
| 51 |
all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
|
| 52 |
for theme, cols in theme_to_cols.items():
|
stats.py
CHANGED
|
@@ -80,8 +80,9 @@ register_stat('IFFB%', pl.col('P'), True, Player.PITCHER, True)
|
|
| 80 |
register_stat('OFFB%', pl.col('F'), True, Player.BATTER, True)
|
| 81 |
register_stat('AIR%', pl.col('F') + pl.col('P') + pl.col('L'), True, Player.BATTER, True)
|
| 82 |
register_stat('HR%', (pl.col('presult') == 'Home run').sum() / pa, True, Player.BATTER)
|
| 83 |
-
register_stat('HR/FB', (pl.col('presult') == 'Home run').sum() / (pl.col('aux_bresult').struct.field('batType')
|
| 84 |
-
|
|
|
|
| 85 |
|
| 86 |
# register_stat('Usage', pl.col('count')/pl.sum('count').over('pitId'), True, None)
|
| 87 |
register_stat('Usage', pl.len()/pl.first('Pitches'), True, None)
|
|
|
|
| 80 |
register_stat('OFFB%', pl.col('F'), True, Player.BATTER, True)
|
| 81 |
register_stat('AIR%', pl.col('F') + pl.col('P') + pl.col('L'), True, Player.BATTER, True)
|
| 82 |
register_stat('HR%', (pl.col('presult') == 'Home run').sum() / pa, True, Player.BATTER)
|
| 83 |
+
register_stat('HR/FB', (pl.col('presult') == 'Home run').sum() / (pl.col('aux_bresult').struct.field('batType').is_in(['F', 'P'])).sum(), True, Player.BATTER)
|
| 84 |
+
# note: to match bouno-san's data, HR/FB bust be /FB for pitchers and /OFFB for batters;
|
| 85 |
+
# /OFFB matches both player types for DeltaGraphs, so we use /OFFB in implementaiton and /FB in na,e
|
| 86 |
|
| 87 |
# register_stat('Usage', pl.col('count')/pl.sum('count').over('pitId'), True, None)
|
| 88 |
register_stat('Usage', pl.len()/pl.first('Pitches'), True, None)
|