Transfer Portal- Scoring Grade
Posted: Tue Jun 11, 2024 3:05 pm
I am attempting to put together a universal python code to rank players per position. I understand PFF is great but I am not paying $120 a year. If anyone would like to help or give me advice I am all ears... this is what I have for WR but AI helped me with most so it definitely could use some adjusting.
# Define player statistics (replace with actual data)
player_stats = {
"Receiving_Yards": 0, # Replace with actual value
"Receiving_TDs": 0, # Replace with actual value
"Avg_Yards_per_Reception": 0, # Replace with actual value
"Longest_Reception": 0, # Replace with actual value
"Rushing_Yards": 0, # Replace with actual value
"Rushing_TDs": 0, # Replace with actual value
"Punt_Return_Yards": 0, # Replace with actual value
"Punt_Return_TDs": 0 # Replace with actual value
# Add more statistics as needed
}
# Define maximum values for normalization
max_values = {
"Receiving_Yards": 1000, # Update with appropriate maximum value
"Receiving_TDs": 10, # Update with appropriate maximum value
"Avg_Yards_per_Reception": 20, # Update with appropriate maximum value
"Longest_Reception": 80, # Update with appropriate maximum value
"Rushing_Yards": 200, # Update with appropriate maximum value
"Rushing_TDs": 5, # Update with appropriate maximum value
"Punt_Return_Yards": 500, # Update with appropriate maximum value
"Punt_Return_TDs": 5 # Update with appropriate maximum value
# Add more maximum values as needed
}
# Define weights for each statistic
weights = {
"Receiving_Yards": 0.3, # Update with appropriate weight
"Receiving_TDs": 0.2, # Update with appropriate weight
"Avg_Yards_per_Reception": 0.1, # Update with appropriate weight
"Longest_Reception": 0.1, # Update with appropriate weight
"Rushing_Yards": 0.1, # Update with appropriate weight
"Rushing_TDs": 0.05, # Update with appropriate weight
"Punt_Return_Yards": 0.05, # Update with appropriate weight
"Punt_Return_TDs": 0.1 # Update with appropriate weight
# Add more weights as needed
}
# Function to calculate performance rating
def calculate_performance_rating(player_stats, max_values, weights):
normalized_stats = {stat: (player_stats[stat] / max_values[stat]) * 100 for stat in player_stats}
performance_rating = sum(normalized_stats[stat] * weights[stat] for stat in normalized_stats)
return performance_rating
# Calculate the performance rating
performance_rating = calculate_performance_rating(player_stats, max_values, weights)
print(f"Performance Rating: {performance_rating:.2f} out of 100")
I ran this for Ty McCullouch and got 42.29/100, Marvin Harrison Jr and got 85.05/100, and Bergen got 60.22 so it seems fair. I need help with the weights of the KPIs (Key Performance Indicators) and the max values for positions. THANKS!
# Define player statistics (replace with actual data)
player_stats = {
"Receiving_Yards": 0, # Replace with actual value
"Receiving_TDs": 0, # Replace with actual value
"Avg_Yards_per_Reception": 0, # Replace with actual value
"Longest_Reception": 0, # Replace with actual value
"Rushing_Yards": 0, # Replace with actual value
"Rushing_TDs": 0, # Replace with actual value
"Punt_Return_Yards": 0, # Replace with actual value
"Punt_Return_TDs": 0 # Replace with actual value
# Add more statistics as needed
}
# Define maximum values for normalization
max_values = {
"Receiving_Yards": 1000, # Update with appropriate maximum value
"Receiving_TDs": 10, # Update with appropriate maximum value
"Avg_Yards_per_Reception": 20, # Update with appropriate maximum value
"Longest_Reception": 80, # Update with appropriate maximum value
"Rushing_Yards": 200, # Update with appropriate maximum value
"Rushing_TDs": 5, # Update with appropriate maximum value
"Punt_Return_Yards": 500, # Update with appropriate maximum value
"Punt_Return_TDs": 5 # Update with appropriate maximum value
# Add more maximum values as needed
}
# Define weights for each statistic
weights = {
"Receiving_Yards": 0.3, # Update with appropriate weight
"Receiving_TDs": 0.2, # Update with appropriate weight
"Avg_Yards_per_Reception": 0.1, # Update with appropriate weight
"Longest_Reception": 0.1, # Update with appropriate weight
"Rushing_Yards": 0.1, # Update with appropriate weight
"Rushing_TDs": 0.05, # Update with appropriate weight
"Punt_Return_Yards": 0.05, # Update with appropriate weight
"Punt_Return_TDs": 0.1 # Update with appropriate weight
# Add more weights as needed
}
# Function to calculate performance rating
def calculate_performance_rating(player_stats, max_values, weights):
normalized_stats = {stat: (player_stats[stat] / max_values[stat]) * 100 for stat in player_stats}
performance_rating = sum(normalized_stats[stat] * weights[stat] for stat in normalized_stats)
return performance_rating
# Calculate the performance rating
performance_rating = calculate_performance_rating(player_stats, max_values, weights)
print(f"Performance Rating: {performance_rating:.2f} out of 100")
I ran this for Ty McCullouch and got 42.29/100, Marvin Harrison Jr and got 85.05/100, and Bergen got 60.22 so it seems fair. I need help with the weights of the KPIs (Key Performance Indicators) and the max values for positions. THANKS!