liveBook · Manning

Pitch type

As explained in Learn AI Data Engineering

A pitch type is a baseball classification describing how a particular pitch is thrown and moves, such as a curveball.

Pitch type is a categorical field for the kind of baseball pitch described in a pitch-level event, such as a four-seam fastball, slider, curveball, changeup, splitter, cutter, sinker, or two-seam fastball. In a structured dataset, it sits beside fields such as pitcher, batter, velocity, count, and result, turning free-form commentary into a value that can be filtered, grouped, and aggregated. section 9.3.1 section 9.3

The value should be extracted from the commentary rather than assumed. A description may name the pitch directly, but it may also omit the type or leave it indeterminate; in that case, use null instead of inventing a label. This matters because model output can vary across prompts, models, and runs, and an incorrect classification can distort later analysis. section 9.3.1 section 9.4

Use pitch type as an analysis-ready field by following a small pipeline discipline:

  • Define pitch_type as an optional string in the target schema, retaining the original play-by-play text and stable pitch identifiers for joining and review. section 9.3.1 section 9.3.2
  • Extract one row per pitch event from natural-language commentary, then combine the extracted value with the source data. section 9.3 section 9.3.2
  • Use a focused extraction pass when pitch type is important. Asking for only this attribute reduces competition with other nuanced fields and can improve robustness. section 9.3.2
  • Aggregate the resulting field for pitch-type distributions, a pitcher’s most frequent pitch, or hitter effectiveness against a named type. section 9.3.1 section 9.4

Focused classification from commentary

For “Scherzer delivers a nasty 88-mph slider that dives out of the zone for ball one,” extract pitch_type as “slider.” Keep the classification separate from velocity and pitch result: 88 mph and ball one are distinct fields. If the commentary does not identify a valid type clearly enough, return null rather than infer one from the outcome or description alone. section 9.3.2

class PitchTypeExtraction(BaseModel):
    pitch_type: Optional[str] = None
 
system_prompt_pitch_type = """
You are a baseball play-by-play data extraction assistant. Extract only the pitch_type from commentary.
Valid pitch types include:
- four-seam fastball
- two-seam fastball
- slider
- curveball
- changeup
- splitter
- cutter
- sinker
 
If pitch type is not mentioned or cannot be determined, return null.

A narrow schema and constrained label list make the extraction task explicit: return one recognized pitch type, or null when the commentary does not determine one. section 9.3.2

Pitch type is useful only as far as extraction quality supports it. Treat it as an AI-generated feature that needs validation and may differ when prompts or model versions change. Isolating the field adds time and cost, but can be preferable when reliable downstream reporting is more valuable than a single broad extraction pass. section 9.4 section 9.3.2

How Learn AI Data Engineering covers it

How deep it goes
Defines an optional schema field and details focused AI extraction, but defers comprehensive baseball pitch mechanics.
Examples
Uses fastball and slider commentary plus pitcher summaries based on most frequent pitch type.
What it assumes
Assumes familiarity with tabular rows and columns while deriving pitch-level fields from natural-language events.
What you can do after
Apply it via an AI extraction pipeline to populate and analyze a structured pitch_type field.
How it connects
Connects pitch type with pitch velocity, pitch result, pitcher performance, batter effectiveness, schema inference, and data validation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn AI Data Engineering. The section links point to the parts of the book it draws on.