← Academic projects

Machine learning

Predicting the career length of NBA players

ENSAI · March to May 2025

How long will a player's career last? And how sure can we be?

≈ 4 yearsaverage error (RMSE)
214unit tests
1946 to 2023seasons covered
01Context

Historical NBA data from 1946 to 2023, spread across several files on players, drafts and game statistics.

02Question

Can a player's career length be predicted from his profile and early performance, with an honest measure of uncertainty?

03Obstacle

The data needed heavy harmonisation (renamed franchises, missing values), many predictors were correlated, and a single predicted number would hide how uncertain each prediction is.

04Choices

How to handle correlated predictors?methodological question

Tension
Multicollinearity makes coefficients unstable.
Choice
Multicollinearity checks and Ridge regularisation, chosen by k-fold cross-validation.

How to communicate uncertainty?methodological question

Tension
A point prediction looks more precise than it is.
Choice
Prediction intervals for each player, shown in a Shiny application.
05Work
  1. Raw files
  2. Harmonisation
  3. Encoding and checks
  4. Ridge regression (k-fold)
  5. Prediction intervals
  6. Shiny app
Illustrative · invented data, shapes only05101520predicted career length (years)Player APlayer BPlayer CPlayer DPlayer EPlayer F
How to read it: the dot is the predicted career length, the band its prediction interval. With an average error of about 4 years, the bands are wide, which is why the app always shows them. Players and values are invented.
06Checks
  • k-fold cross-validation.
  • 214 unit tests on the modelling class and the application.
07Outcome

A tested model and an interactive application. Age at entry, position and performance indicators were among the most important predictors.

Interactive Shiny app used to explore career-length predictions.
Interactive Shiny app used to explore career-length predictions.
08Limits

What remains open

  • An error of about 4 years is large for one player: the model is useful for trends, not for individual decisions.

What I took from it

  • Show uncertainty explicitly instead of hiding it behind one number.

The whole project in one sentenceA regularised regression on seasons from 1946 to 2023 predicts career length with an error of about 4 years, and the Shiny app shows every prediction with its interval so that a trend is never mistaken for a certainty.