Player comps / the warehouse behind the tool
Query the pitch warehouse
This is the data pipeline under the player comps tool (opens in a new tab). Every pitch of two seasons lands from Baseball Savant in PostgreSQL as delivered. dbt then builds the labeled pitches, the hitter seasons and the count matrix the topic model reads, and it runs a set of tests on the way. The tables are served here as Parquet files and SQL runs in your browser. The two pitch-level tables are one sample week, because the full tables hold 1.4 million rows each. Everything else is complete.
The project page says what the model found. The Gamebot page (opens in a new tab) is the same machinery over a TV show, and Jobwatch (opens in a new tab) over job postings.
Lineage
Every table, by layer, with the dependencies dbt declares. Click a table for its columns, its tests and their status from the last build, and for silver and gold the SQL that builds it. Bronze is Savant's export as delivered, as text, with the batch it arrived in. Silver casts and labels. Gold is what the model and the page read. A dashed table is served as a sample.
SQL
DuckDB runs in the page and reads each table's Parquet file on demand, so a query fetches only what it names. Tables are bronze.statcast_pitches, silver.pitches, gold.count_matrix and the rest of the lineage map. Clicking a table name in the sidebar writes a starter query.
One hitter, one row of the count matrix
The gold count matrix has a row per hitter and season and a column per word. Pick a season and a hitter to see that row, grouped by pitch class and attack zone, with the hitter's percentile among that season's qualified hitters on each word. A word is what was thrown, where it crossed the plate, and what the hitter did.
Tests
Every dbt test in the project and its status from the last build, by table. The three the design asked for are here. Every pitch has a word or a stated reason for none, the attack-zone rings partition every located pitch, and the contact classes cover every ball in play with tracking.
Data: Statcast pitch-level data through Baseball Savant's search export, read through pybaseball, and the Chadwick Bureau register. Bronze holds Savant's fields as delivered. Built by Max Grody.