timmymatten8/pitch_data_explorer
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
MLB Pitcher Data Exploration Dashboard
A Python dashboard application for exploring and visualizing 2024 MLB pitcher statistics using interactive plots and filters.
Overview
This project provides an interactive web-based dashboard to analyze MLB pitcher performance data from the 2024 season. The dashboard features scatter plots of velocity vs. spin rate and line charts showing pitch usage over time, with dynamic filtering capabilities.
Features
- Interactive Scatter Plot: Visualize velocity vs. spin rate for selected pitchers and pitch types
- Line Chart Analysis: Track pitch usage patterns over the 2024 season
- Dynamic Filtering: Filter by pitcher and pitch types with real-time updates
- Customizable Plots: Adjust plot dimensions for optimal viewing
- Clean Interface: Organized sidebar controls with tabbed main display
Project Structure
├── baseballexplore.py # Main dashboard application
├── data_scrape.py # Data collection script using pybaseball
├── savant_data_api.py # Data API for processing and filtering
└── savant_data.csv # MLB Statcast data (generated by data_scrape.py)Installation
- Install required dependencies:
pip install panel pandas matplotlib pybaseball- Generate the dataset:
python data_scrape.py This will download 2024 MLB data and save it as savant_data.csv
- Run the dashboard:
python baseballexplore.pyUsage
Once the dashboard is running, you can:
- Select a pitcher from the dropdown menu in the "Scatter Plot Filters" section
- Choose pitch types to display using the checkbox group
- Adjust plot dimensions using the width and height sliders
- Switch between tabs to view scatter plots or line charts
- Analyze pitch usage over time using the line chart tab
Data Source
The project uses MLB Statcast data obtained through the pybaseball library, covering the entire 2024 MLB season. The data includes detailed pitch-by-pitch information such as:
- Release speed and spin rate
- Pitch types and locations
- Game dates and contexts
- Player information
Technical Details
Dependencies
- Panel: Web-based dashboard framework
- Pandas: Data manipulation and analysis
- Matplotlib: Plotting and visualization
- PyBaseball: MLB data acquisition
Data Processing
The SAVANT_DATA_API class handles data loading and filtering operations, providing methods to:
- Load and clean raw Statcast data
- Filter data by pitcher and pitch type
- Calculate statistical summaries
- Generate organized data subsets for visualization
Dashboard Components
- Sidebar Controls: Pitcher selection, pitch type filters, and plot customization
- Tabbed Interface: Separate views for scatter plots and line charts
- Reactive Updates: Automatic refresh of available options when selections change
Author
Tim Matten
Notes
- The dashboard is designed to handle the full 2024 MLB dataset, which may contain hundreds of thousands of pitch records
- Initial load time may vary depending on dataset size
- Default pitcher selection is set to "Cole, Gerrit" for demonstration purposes
