Self-paced course · Intermediate · 43 lessons

PREDICT THE WIN.

Python MachineZ: ML in Sports

Build and evaluate the machine-learning models sports teams actually use in Python, from regression to neural nets.

An agent can write the model. This course is about knowing when it is wrong.

Who it is for. Python users who want to build real machine-learning models on sports data, end to end.

$499 Enroll now One payment, lifetime access. Included with Membership.
Why take this

Three things you leave with.

A full ML pipeline in scikit-learn

GLMs, GAMs, trees, and neural networks on real sports data

Honest model evaluation and selection

Not for you if
  • You've never written Python
  • You want R, not Python
  • You want theory without building
  • You want a shallow survey, not applied depth
Play with the data

Run the code, in your browser.

The chart on this page, drawn by code you can edit. R runs on webR and Python on Pyodide; nothing loads until you press Run, and nothing you type leaves the page.

This chart is the code's result. Run recomputes it in your browser.
Swings and misses in a grid over the plate, catcher's view, with the strike zone drawn. Pick a pitch type; hover a cell for the count.

Edit me: Set cell to 0.25 for a finer grid, or min_swings to 20 for steadier rates, and run again.

Data: Pitch movement and whiffs (pitch_movement.csv). Simulated for practice by AthlyticZ (agents/sim_data.py, seed 20261109). License CC BY 4.0.

The code runs in your browser on webR or Pyodide; nothing you type leaves the page.

What you get

Everything that exists for this course, and nothing that does not.

  • Every lesson43 lessons in 11 sections, yours to keep
  • Project files and codeEvery notebook, dataset and finished build, to keep and adapt
Patrick McFarlane
Your instructor Patrick McFarlane

Director of Predictive Modeling @ Philadelphia Phillies

Teaches the course the way the work is done in the role above. The team page lists everything they teach here.

The problem

Predicting a result in sport is easy to do badly: leakage, the wrong metric and an untested model all look fine until the season starts.

Three decisions it teaches
  1. How to frame the prediction and choose the evaluation criterion before fitting anything
  2. How to build and compare models in scikit-learn without the answer leaking into the features
  3. How to read model behavior and know what it has learned

The artifact. Prediction models on sports data with honest evaluation, from feature engineering to a validated result.

Pythonagents/viz/python-machinez.py
2026-11-09T02:12:26.293631 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 65 70 75 80 85 90 95 100 release speed, mph 0.0 0.2 0.4 0.6 0.8 1.0 P(pitch type | speed) Speed alone gets 67% right on held-out pitches: the overlap is where the model is unsure CH CU FF SL
Can a model tell the pitch type from release speed alone? A classifier on six thousand pitches, scored honestly on held-out data. Drawn at build from the data on this site by the code below.
The code that drew it
# Can a model tell the pitch type from release speed alone? A classifier on six thousand pitches, scored honestly on held-out data.
import sys, pathlib, csv
sys.path.insert(0, str(pathlib.Path(__file__).parent))
from _palette import plt, emit, GOLD, TEAL, AQUA, CREAM, MUTE
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.ensemble import GradientBoostingClassifier

rows = list(csv.DictReader(open("site/18-practice/pitch-speeds/files/pitches_2026.csv")))
X = np.array([[float(r["release_speed"])] for r in rows]); y = np.array([r["pitch_type"] for r in rows])
Xtr, Xte, ytr, yte = train_test_split(X, y, test_size=0.3, random_state=3, stratify=y)
clf = GradientBoostingClassifier(random_state=3).fit(Xtr, ytr)
acc = (clf.predict(Xte) == yte).mean()
grid = np.linspace(65, 102, 300)[:, None]; proba = clf.predict_proba(grid)
fig, ax = plt.subplots(figsize=(7.2, 4.0))
cols = {"FF": GOLD, "SL": TEAL, "CH": AQUA, "CU": CREAM}
for j, c in enumerate(clf.classes_):
    ax.plot(grid[:, 0], proba[:, j], lw=1.8, color=cols.get(c, MUTE), label=c)
ax.set_xlabel("release speed, mph"); ax.set_ylabel("P(pitch type | speed)"); ax.set_ylim(0, 1)
ax.set_title(f"Speed alone gets {acc:.0%} right on held-out pitches: the overlap is where the model is unsure")
ax.legend(frameon=False, fontsize=9)
emit(fig)

Data: Pitch speeds by type. Simulated for practice by AthlyticZ (agents/sim_data.py, seed 20261109). License CC BY 4.0.

Curriculum

Every section, every lesson.

From the academy course record, in the order it is taught. The first section is open; the rest fold out.

43 lessons in 11 sections, 11 quizzes. Every lesson is yours to keep.

Introduction to Advanced Machine Learning in Sports Analytics5 items
  1. Machine Learning in Sports
  2. Overview of Sports Data
  3. Overview of Machine Learning
  4. Syllabus Review
  5. QUIZ: Intro to Python MachineZ quiz
Linear Regression and The Machine Learning Pipeline6 items
  1. Linear Regression and Least Squares
  2. Predicting PGA Tour Drive Distance
  3. Dataset Splits
  4. Normalizing and Regularization
  5. Model Construction and Performance
  6. QUIZ: Linear Regression & ML Pipeline quiz
Exploratory Data Analysis and Feature Engineering4 items
  1. Motivating Data Exploration
  2. Data Visualization
  3. Feature Engineering
  4. QUIZ: EDA & Feature Engineering quiz
Hyperparameter Tuning and Model Selection5 items
  1. Introduction to Hyperparameters
  2. Cross Validation
  3. Hyperparameter Tuning
  4. Model Selection
  5. QUIZ: HP Tuning and Model Selection quiz
Model Performance Evaluation4 items
  1. Performance Metrics
  2. Choosing Evaluation Criteria
  3. Exploring Model Behavior
  4. QUIZ: Model Performance Evaluation quiz
Automating Machine Learning Pipelines4 items
  1. Motivating Machine Learning Pipelines
  2. Scikit-Learn Pipelines
  3. Pycaret
  4. QUIZ: Automating ML Pipelines quiz
Generalized Linear Models5 items
  1. Motivating Generalized Linear Models
  2. Outcome Distributions
  3. Link Functions
  4. NFL Field Goal Probability
  5. QUIZ: Generalized Linear Models quiz
Generalized Additive Models4 items
  1. Motivating Generalized Additive Models
  2. Basis Functions and B-Splines
  3. NBA In-Game Win Probability
  4. QUIZ: Generalized Additive Models quiz
Tree-based Methods6 items
  1. Motivating Tree-based Methods
  2. Decision Trees
  3. Random Forest
  4. Gradient Boosting Machines
  5. WNBA Shot Probability
  6. QUIZ: Tree-Based Methods quiz
Neural Networks6 items
  1. Motivating Neural Networks
  2. Neural Network Architecture
  3. Backpropagation
  4. Hyperparameters and Best Practices
  5. Revisiting NBA In-Game Win Probability
  6. QUIZ: Neural Networks quiz
Introduction to Applied Bayesian Statistics5 items
  1. Bayes' Theorem and Sampling
  2. Introduction to PyMC
  3. Revisiting WNBA Shot Probability
  4. Wrapping Up
  5. QUIZ: Intro to Applied Bayesian Stats quiz
What is included

What is yours when you enroll.

  • Lifetime access Every module and lesson, yours to keep and revisit, forever.
  • Project files and code Every notebook, dataset, and finished build, to keep and adapt.
  • All future updates New lessons and refreshes as the tools move, at no extra cost.
  • Self-paced Start today, go at your own pace, no cohort to wait for.

Refunds. If you enrolled and it is the wrong course for you, write to michael@athlyticz.com and a person will answer.

Questions

The ones that stop a purchase.

Is this included with Membership?

Yes. Membership includes this and the entire course catalog, plus the live Masterclass. If you plan to take more than a couple of courses, Membership is the better math.

Is this too advanced, or too basic, for me?

Python users who want to build real machine-learning models on sports data, end to end. If the "not for you" list above reads like you, start elsewhere; if the outcome at the top reads like something you could use next week, it is pitched right.

What exactly do I get, and for how long?

11 sections · 43 lessons. Every lesson, the project files and code, and all future updates. Lifetime access: it is yours to keep.

Is it self-paced?

Yes. Start today and go at your own pace, with lifetime access to every lesson and all future updates.

Python MachineZ: ML in Sports

Build and evaluate the machine-learning models sports teams actually use in Python, from regression to neural nets.

This course $499 one payment, lifetime access

11 sections · 43 lessons, the project files, and every future update.

Enroll now
Membership $2,999 a year

This course, the whole catalog, and the Masterclass: every live session and every recording.

Get Membership