Skip to main content

Match Predictions based on Player Ratings

Project description

player-performance-ratings

Framework designed to predict outcomes in sports games using player-based ratings. Ratings can be used to predict game-winner, but also other outcomes such as total points scored, total yards gained, etc.

Installation

pip install player-performance-ratings

Example Useage

Ensure you have a dataset where each row is a unique combination of game_ids and player_ids. Even if the concept of a player doesn't exist in the dataset, you can use team_id instead of player_id.

Utilizing a rating model can be as simple as:

from player_performance_ratings import ColumnNames, PredictColumnNames
from player_performance_ratings.examples.internal_utils import load_nba_game_player_data


from player_performance_ratings.ratings import OpponentAdjustedRatingGenerator
column_names = ColumnNames(
    team_id='team_id',
    match_id='game_id',
    start_date="start_date",
    player_id="player_id",
    performance="won",
)

#Below assumes you have loaded your data into a pandas dataframe
df[PredictColumnNames.TARGET] = df['won']

# define configuration wiht the column names mapping to your dataframe

df = df.sort_values(by=[column_names.start_date, column_names.match_id, column_names.team_id, column_names.player_id])
rating_generator = OpponentAdjustedRatingGenerator()

#below returns all historical match-by-match ratings for each player
generated_ratings = rating_generator.generate(df=df, column_names=column_names)

#below returns the most up-to-date ratings for each player
player_ratings = rating_generator.player_ratings

#below returns the most up-to-date ratings for each team
team_ratings = rating_generator.team_ratings

For more advanced usecases, check the examples directory.

Description

The flexibility of the rating model grants the potential for significantly higher accuracy than other models, such as Elo,Glicko and Trueskill which are based on team performance. Both team and player outcomes can be predicted. The user has freedom to combine the ratings with other features, such as home/away, weather, etc. The user can also use some of the already created machine-learning models or create any custom model that they believe will work better.

The framework consists of the following components:

Preprocessing

If the intention is a simple elo-model or equivalent, no preprocessing is required. However, typically a lot of value can be gained through intelligent preprocessing before the ratings are calculated. The rating-model will take a performance_column as input and update ratings on that. A well designed performance that is a good indicator of future success is crucial for the model to work well. For instance, if the user suspects that a players true shooting percentage is a better indicator of future points scored by the player than actual points scored, the user can use that. Or, user can also use a combination of statistics, such as true shooting percentage and points scored to calculate the "match-performance".

The user can configure classes inside the preprocessing folder to create the performance_column. The user can also create custom classes with more specific functionality.

Rating Calculation

PostProcessing

Model Predictions

Scoring

Hyperparameter Tuning

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

player-performance-ratings-4.8.5.2.tar.gz (58.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

player_performance_ratings-4.8.5.2-py3-none-any.whl (76.2 kB view details)

Uploaded Python 3

File details

Details for the file player-performance-ratings-4.8.5.2.tar.gz.

File metadata

File hashes

Hashes for player-performance-ratings-4.8.5.2.tar.gz
Algorithm Hash digest
SHA256 e6cc5252876b1f6e88b8604cefad538cd9316e40d4364ccb3ab5bfa0a18d31b6
MD5 1330db301a295b4693ef3187234e979d
BLAKE2b-256 fd02b2d8b17b925e95160f7941473a874e4449f74f81c619c32c4a02eafebc80

See more details on using hashes here.

File details

Details for the file player_performance_ratings-4.8.5.2-py3-none-any.whl.

File metadata

File hashes

Hashes for player_performance_ratings-4.8.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6d8ae794792ce704c5ef1e29bb5c0b0beea1b8ab446f5004c869458e446f90a0
MD5 323c33eb12147104d2e5a8a57e793e7f
BLAKE2b-256 1796092edb39e0ff1bdb85a59723d3f402c78f7a1081fab046a455592f7f7c37

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page