Skip to content

duncanwold/bayesian-ticket-forecast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bayesian Ticket Forecast

Forecast Visualization

A Bayesian statistical forecasting tool for predicting ticket sales at live event venues. Originally developed for PianoFight Theater in San Francisco.

Overview

This application uses historical event data to predict final ticket sales for upcoming shows. By analyzing patterns from past events with similar characteristics (venue, timing, initial sales velocity), it generates probabilistic forecasts with confidence intervals.

Features

  • Bayesian Probability Model — Calculates likelihood of various sales outcomes based on historical data
  • Real-time Forecasting — Projects final ticket sales based on current sales and time until event
  • Interactive Visualizations — Dynamic plots showing probability distributions and sales trajectories
  • Credible Intervals — Statistical confidence ranges for predictions
  • Historical Pattern Matching — Identifies similar past events to improve forecast accuracy
  • Multi-venue Support — Handles different venue capacities

How It Works

The Forecasting Algorithm

  1. State Definition — Defines a "state" based on current conditions:

    • Number of tickets sold (with tolerance range)
    • Time until event start (with tolerance range)
    • Venue type
  2. Historical Analysis — Scans historical events to find matches:

    • Filters for events that passed through the defined state
    • Tracks their final attendance numbers
  3. Bayesian Calculation — Computes probabilities:

P(final_tickets | current_state) = P(current_state | final_tickets) 
× P(final_tickets) / P(current_state)
  1. Smoothing — Applies weighted smoothing to reduce noise in the probability distribution

  2. Confidence Intervals — Calculates credible intervals at specified confidence levels

Key Parameters

  • Initial Tickets — Current number of tickets sold
  • Ticket Delta — Tolerance range for matching similar sales levels (±)
  • Time Until Event — Days/hours until the event starts
  • Time Delta — Tolerance range for matching similar timeframes (±)
  • Smooth By — Smoothing factor for probability distribution
  • Confidence Interval — Desired confidence level (e.g., 80%)

Technical Stack

  • Frontend — Vanilla JavaScript, HTML5, CSS3
  • Data Visualization — Plotly.js
  • UI Components — Chosen.js for enhanced select dropdowns
  • Data Source — Ticketing API (via JSON exports)
  • Statistical Method — Bayesian inference

Data Structure

The application expects JSON data files exported from a ticketing platform API:

  • events-all.JSON — Event data
  • attendees.JSON — Ticket purchase records
  • venues.JSON — Venue information
  • reconStats.JSON — Reconciliation statistics

Usage

Basic Forecast

  1. Set Initial State parameters:

    • Select venue
    • Enter current tickets sold
    • Enter time until event (days + hours)
  2. Adjust Tolerances:

    • Ticket Delta: How much variance in ticket counts to include
    • Time Delta: How much variance in timing to include
  3. Configure Visualization:

    • Smoothing factor
    • Confidence interval percentage
    • Toggle mean line and confidence interval display
  4. Click Forecast to generate prediction

Interpreting Results

  • Most Likely Final Tickets — Expected final attendance (mean of distribution)
  • Credible Interval — Range where actual result is likely to fall
  • Probability Distribution — Shows likelihood of each possible outcome
  • Matching Events — Number of historical events that matched your criteria

Order Visualization

  • Enter an Event ID to see ticket sales over time
  • Visualize sales velocity and patterns
  • Compare against initial state to see when conditions were met

Use Cases

  • Revenue Forecasting — Predict box office performance early in the sales cycle
  • Marketing Decisions — Identify shows that need a promotional boost
  • Capacity Planning — Optimize staffing and resource allocation
  • Show Selection — Evaluate the potential of different productions
  • Pricing Strategy — Adjust ticket prices based on demand predictions

Statistical Approach

Why Bayesian?

Traditional forecasting methods often assume linear relationships or require extensive feature engineering. The Bayesian approach:

  • Allows a reasonable forecast to be generated with minimal data
  • Handles uncertainty naturally through probability distributions
  • Incorporates historical patterns without overfitting
  • Provides interpretable confidence intervals
  • Works well with limited data by leveraging similar events

Key Insights

  • Shows with similar initial sales velocities tend to have similar final outcomes
  • Time until event is a critical factor — urgency drives late sales
  • Venue capacity creates natural ceiling effects
  • Historical patterns from the same show or organizer improve predictions

Development Notes

  • Data is cached with random query parameters to prevent browser caching
  • Unlisted events are automatically filtered out
  • Free, refunded, and cancelled tickets are excluded from analysis
  • Attendee data is sorted by purchase date for temporal analysis

Future Enhancements

  • Weight events by room capacity and extend model to all capacities
  • Add seasonality factors (day of week, time of year, etc.)
  • Allow venues to opt in to share data and improve models collectively
  • Real-time API integration instead of cached JSON
  • Machine learning ensemble with traditional time series models
  • Mobile-responsive design
  • Export forecast reports
  • Generalize data adapter layer for multiple ticketing platforms

Performance

  • Processes 1,000+ historical events in real time
  • Sub-second forecast generation
  • Interactive visualizations with smooth rendering
  • Efficient filtering and probability calculations

Note on Data Files

This repository contains the application code only. Actual event data files are not included as they contain sensitive business information. To run this application you would need to supply your own data exports from a compatible ticketing platform API in the following format:

  • events-all.JSON — Event data
  • attendees.JSON — Ticket purchase records
  • venues.JSON — Venue configuration
  • reconStats.JSON — Reconciliation statistics

License

MIT License — see LICENSE file for details

Author

Originally built for PianoFight Theater's operations team in 2018. Open sourced as a portfolio project demonstrating practical application of Bayesian statistics and real-time data visualization in the live entertainment industry.

About

Bayesian statistical forecasting tool for predicting ticket sales using historical event data

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors