-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCategorization.py
192 lines (168 loc) · 7.38 KB
/
Categorization.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/usr/bin/env python
# coding: utf-8
#
# # Offense:
#
# **Pure Shooter/Stretcher**:
#
# - Three-Point Shooting Percentage (3P%): Indicates the player's accuracy from beyond the arc.
# - Three-Point Attempt Rate (3PAr): Measures the proportion of field goal attempts taken from three-point range.
# - Effective Field Goal Percentage (eFG%): Reflects a player's shooting efficiency, giving extra weight to three-pointers made.
# - Usage Rate (USG%): Provides insight into how involved the player is in the team's offensive possessions.
#
# **Slasher**:
#
# - Field Goal Percentage (FG%): Measures overall shooting accuracy.
# - Percentage of Field Goals Attempted within 0-10 Feet (FGA 0-10 ft): Shows the player's tendency to attack the basket.
# - Free Throw Rate (FTR): Indicates how frequently the player gets to the free-throw line relative to their field goal attempts.
# - Drives Per Game: Quantifies how often the player attempts to penetrate into the paint off the dribble.
#
# **Versatile Scorer**:
#
# - Standard Deviation of Field Goal Percentages: Reflects consistency in shooting across different zones.
# - Points Per Possession (PPP) in Isolation and Pick & Roll: Highlights scoring efficiency in isolation and pick-and-roll situations. *not sure if pertinent*
# - Assists per Game (AST): Demonstrates the player's ability to create scoring opportunities for teammates.
#
# **Paint Threat**:
#
# - Percentage of Field Goals Attempted within 0-3 Feet (FGA 0-3 ft): Indicates proficiency in scoring close to the basket.
# - Offensive Rebound Percentage (ORB%): Reflects the player's ability to grab offensive rebounds.
# - Effective Field Goal Percentage (eFG%): Reflects a player's shooting efficiency, favorising players with a high 2FG%.
#
# **Creator/Facilitator**:
#
# - Assist Percentage (AST%): Reflects the percentage of teammate field goals a player assists on while on the court.
# - Usage Rate (USG%): Indicates the player's involvement in initiating and orchestrating offensive plays.
# - Assist-to-Turnover Ratio (AST/TO): Highlights the player's ability to facilitate scoring while minimizing turnovers.
#
# # Defense:
#
# **Paint Protector/Rim Defender**:
#
# - Defensive Rebound Percentage (DRB%): Reflects the player's ability to secure defensive rebounds.
# - Blocks Percentage (BLK%): Measures the player's shot-blocking prowess.
# - Opponent Field Goal Percentage at the Rim: Indicates the effectiveness of the player in deterring shots near the basket.
# - Defensive Box Plus/Minus (DBPM): Provides an estimate of the player's defensive contribution per 100 possessions. *maybe WS would be more convenient?*
#
# **Perimeter Lockdown Defender**:
#
# - Steals percentage (STL%): Quantifies the player's ability to disrupt passing lanes and create turnovers.
# - Deflections Per Game: Indicates the player's activity in deflecting passes and disrupting offensive plays.
# - Defensive Box Plus/Minus (DBPM): Provides an estimate of the player's defensive contribution per 100 possessions. *maybe WS would be more convenient?*
# - Opponent Field Goal Percentage: Reflects the shooting efficiency of opponents when guarded by the player.
#
# **Switchable Defender**:
#
# - Defensive Versatility Index: Reflects the player's ability to guard multiple positions effectively.
# - Defensive Win Shares (DWS): Quantifies the player's defensive contribution to team wins.
# - Pick & Roll Defensive Efficiency: Measures effectiveness in defending pick-and-roll plays.
# - Defensive Rebound Percentage (DRB%): Shows the player's ability to secure rebounds on the defensive end.
#
# **Rebounding Specialist**:
#
# - Total Rebound Percentage (TRB%): Reflects the player's ability to secure both offensive and defensive rebounds.
# - Offensive Rebound Percentage (DRB%): Indicates the player's effectiveness in grabbing offensive rebounds.
# - Box Outs Per Game: Demonstrates the player's effort in boxing out opponents to secure rebounds.
#
# **Defensive Anchor**:
#
# - Defensive Box Plus/Minus (DBPM): Provides an estimate of the player's defensive contribution per 100 possessions. *maybe WS would be more convenient?*
# - Overall defensive statistics : combine (blocks, steals, deflection, box out)
# - Opponent Field Goal Percentage Differential: Compares the shooting efficiency of opponents when the player is on and off the court.
# In[ ]:
# In[2]:
def offensive_profile(player_stats, player_stats_ranked) -> str:
"""
Determine the offensive category of a player based on their statistics.
Args:
- player_stats (pd.Series): A pandas Series containing the offensive statistics of a player.
Returns:
- str: The offensive category of the player.
"""
## Creator/Facilitator
if (
(player_stats["AST%"] >= 25.0)
and (player_stats["USG%"] >= 20.0)
and (player_stats["AST/TOV"] >= 1.5)
):
return "Creator/Facilitator"
## Pure Shooter/Stretcher:
elif (
(player_stats["3P%"] > 0.37)
and (player_stats["3PAr"] > 0.5)
and (player_stats_ranked["eFG% ranked"] <= 4)
and (player_stats["USG%"] <= 20.0)
):
return "Pure Shooter/Stretcher"
# Paint Threat
elif (
(player_stats["%FGA 0-3"] > 0.5)
and (player_stats_ranked["ORB% ranked"] <= 3)
and (player_stats_ranked["eFG% ranked"] <= 3)
):
return "Paint Threat"
## Slasher
# elif (
# (player_stats["%FGA 0-3"]) > 0.2
# and (player_stats["%FGA 3-10"] + player_stats["%FGA 10-16"]) > 0.2
# and (player_stats_ranked["FTr ranked"] <= 4)
# and (player_stats["%FGA 3P"] < 20.0)
# ):
# return "Slasher"
# Slasher
elif (
(player_stats["2P%"] > 0.50)
and (player_stats["FTr"] > 0.2)
and (player_stats_ranked["%FGA 0-3 ranked"] <= 5)
and (player_stats_ranked["%FGA 3-10 ranked"] <= 6)
):
return "Slasher"
## Versatile Scorer
elif (
(player_stats_ranked["std_areas_FGA ranked"] >= 5)
and (player_stats["USG%"] >= 20.0)
and (player_stats_ranked["FG ranked"] <= 5)
):
return "Versatile Scorer"
else:
return "No significant offensive role"
def defensive_profile(player_stats, player_stats_ranked) -> str:
"""
Determine the defensive category of a player based on their statistics.
Args:
- player_stats (pd.Series): A pandas Series containing the statistics of a player.
Returns:
- str: The defensive category of the player.
"""
## Paint Protector/Rim Defender
if (
player_stats["DRB%"] >= 25.0
and player_stats_ranked["BLK% ranked"] <= 3
and player_stats_ranked["DBPM ranked"] <= 4
):
return "Paint Protector"
## Perimeter Defender
elif (
player_stats["STL%"] >= 1.5
and player_stats_ranked["DBPM ranked"] <= 4
and player_stats["STL"] >= 0.8
):
return "Perimeter Defender"
## Switchable Defender
elif (
player_stats["DRB%"] >= 20.0
and player_stats_ranked["BLK% ranked"] <= 6
and player_stats["STL"] >= 0.5
and player_stats_ranked["DBPM ranked"] <= 4
and player_stats_ranked["DWS ranked"] <= 4
):
return "Switchable Defender"
## Rebounding Specialist
elif (
player_stats["TRB%"] >= 10.0
and player_stats_ranked["DRB% ranked"] <= 2
and player_stats["DRB%"] >= 20.0
):
return "Rebounding Specialist"
else:
return "No significant defensive role"