Skip to content

AI-Powered Baseball Strategy Analyser with real-time pitch explanations using MLB data & Gemini API. Includes Python & Streamlit, built for fans, analysts, and developers.

License

Notifications You must be signed in to change notification settings

Eusha425/mlb-strategy-assistant

Repository files navigation

Baseball Strategy Assistant

An AI-powered tool that explains baseball pitch strategies in real-time using MLB data and Google's Gemini API.

FeaturesInstallationUsageProject StructureContributing

Overview

The Baseball Strategy Assistant is a real-time AI tool that analyses MLB game data and provides casual fans with fun, easy-to-understand explanations of pitch strategies. Built with Python, Streamlit, and Google's Gemini API, it transforms complex baseball tactics into relatable analogies.

Features

  • Real-Time Insights: Fetches live game data from MLB's API
  • AI-Powered Analysis: Uses Gemini to generate casual, fun explanations
  • Interactive UI: Built with Streamlit for a clean, user-friendly experience
  • Multilingual Support: Gemini can explain strategies in multiple languages
  • Historical Data: Works with past games for demo purposes

Prerequisites

  • Python 3.9+
  • Google Gemini API Key (Get it here)
  • MLB API Access (Public, no key required)

Installation & Setup

  1. Clone the repository

    git clone https://github.com/Eusha425/baseball-strategy-assistant.git
    cd baseball-strategy-assistant
  2. Set up a virtual environment

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables Create a .env file in the root directory:

    GEMINI_API_KEY=your_api_key_here

Usage

  1. Run the app locally

    streamlit run main.py
  2. View the app Open your browser and navigate to http://localhost:8501

  3. Interact with the app

    • The app automatically fetches live game data
    • If no live games are available, it uses historical data for demonstration
    • View real-time pitch insights with fun analogies!

Project Structure

baseball-strategy-assistant/
├── main.py                # Streamlit app entry point
├── mlb_client/            # MLB API interactions
│   └── __init__.py
├── gemini_client/         # Gemini API integration
│   └── __init__.py
├── date_utils/            # Date-related utilities
│   └── __init__.py
├── .env                   # Environment variables
├── requirements.txt       # Python dependencies
└── README.md              # Project documentation

Performance

  • Latency:
    • MLB API: ~200ms
    • Gemini API: ~500ms
  • Supported Games:
    • Live MLB games (when available)
    • Historical games (fallback)

Contributing

Contributions are welcome! Here's how you can help:

  1. Report Bugs: Open an issue with detailed steps to reproduce
  2. Suggest Features: Share your ideas for new features or improvements
  3. Submit Pull Requests: Follow the Contributing Guidelines

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

  • MLB API: For providing free access to live game data
  • Google Gemini: For enabling AI-powered insights
  • Streamlit: For making web app development simple and fast

About

AI-Powered Baseball Strategy Analyser with real-time pitch explanations using MLB data & Gemini API. Includes Python & Streamlit, built for fans, analysts, and developers.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages