Back to Portfolio

Sports Edge

An automated machine learning pipeline that predicts NBA and NFL outcomes by analyzing advanced metrics, rest situations, and market inefficiencies.

PythonBigQueryGCPNext.jsLightGBMSupabase
Loading model edges…
Win Rate (7d)
62.5%
Predictions
1,240+
Data Points
850K
Pipeline
100% Auto

System Architecture

Data Ingestion

Scraping NBA/NFL APIs & Odds APIs daily via GitHub Actions.

Feature Engineering

Rolling averages, rest calc, and situational spots processed in BigQuery.

Inference

LightGBM models score games & push predictions to Supabase.

Pipeline Logic

The core pipeline handles everything from checking data freshness to ensuring idempotent writes in BigQuery. Here is how we handle the daily NBA prediction flow:

refresh_nba.py
def main() -> None:
    load_dotenv()
    args = _parse_args()
    client = bigquery.Client(project=args.project)

    target_date = args.date or datetime.now(tz=timezone.utc).date()
    # ... setup context ...

    games_df = _query_games(client, args.project, target_date)
    if games_df.empty:
        # Fallback to API if BigQuery is empty
        games_df = fetch_nba_games_for_date(target_date.strftime("%Y-%m-%d"), raise_on_error=True)

    # ... load historical data ...
    
    # Predictor handles feature building automatically
    predictor = GamePredictor("NBA", model_version=args.model_version)
    predictions = predictor.predict_batch(games_df, historical_games, game_logs=game_logs)
    
    # ... result processing & BQ write ...
    _delete_existing_predictions(client, args.project, predictions["game_id"].dropna().tolist(), args.model_version)
    # ... Write to BigQuery ...

Ask the Data

This MVP assistant routes questions to SQL for current results and to project documentation for methodology, limitations, and metric definitions.

Sports Edge Chat

Hybrid assistant: SQL summaries for results + documentation retrieval for methodology.

Ask about Sports Edge results, methodology, or risk. I can combine live SQL stats with portfolio documentation.