Skip to main content

Event Prediction for Places

Overview

The predict_place_events Django management command uses a rule-based machine learning approach to predict whether a place is likely to host events based on its description, categories, vibes, and historical data.

Command Location

api/management/commands/predict_place_events.py

How It Works

The prediction system uses a weighted scoring approach based on four key features.

Text Extraction

The command uses the comprehensive get_text_from_place() function from etl.utils.listing_utils which aggregates:

  • Place name and descriptions
  • text_full property (includes all text from data sources)
  • Tips and user-contributed content
  • Reviews from various platforms
  • Text from all data source descriptions

This rich text extraction provides significantly better prediction accuracy compared to using just the basic description field.

1. Keyword Analysis (Weight: 3.0)

Scans place descriptions for event-related keywords such as:

  • Event-specific terms: "event", "concert", "show", "performance", "venue", "stage"
  • Activity types: "live music", "comedy", "theater", "workshop", "class", "seminar"
  • Booking indicators: "tickets", "admission", "reservations", "rsvp", "booking"
  • Entertainment: "nightclub", "dj", "festival", "screening"

2. Category Matching (Weight: 2.5)

Checks if the place belongs to categories commonly associated with events:

  • Venues: "venue", "music-venue", "concert-hall", "theater", "event-space"
  • Nightlife: "bar", "club", "nightclub", "lounge"
  • Arts & Culture: "gallery", "museum", "cultural-center"
  • Dining: "restaurant", "cafe", "brewery", "winery"

3. Vibe Analysis (Weight: 1.5)

Evaluates the vibes associated with the place:

  • "lively", "fun", "exciting", "energetic", "vibrant"
  • "entertainment", "nightlife", "social", "festive"

4. Historical Event Count (Weight: 10.0)

Strongly weights places that have previously hosted events:

  • Base score if event_count > 0
  • Additional bonus for venues with 5+ events

Detects event ticketing/listing platform links in place data sources:

  • Checks for Eventbrite, Ticketmaster, StubHub, Bandsintown, Songkick, and 15+ other platforms
  • Scans both URLs and data source names in the data_sources field
  • Strong signal - if a place has event platform links, they're actively hosting events
  • Supported platforms include:
    • Ticketing: Eventbrite, Ticketmaster, StubHub, SeatGeek, AXS, Universe
    • Music: Bandsintown, Songkick, Resident Advisor (ra.co)
    • General: Meetup, Allevents, and many more

Prediction Threshold

A place is predicted to host events if its total score >= 5.0. Confidence is calculated as:

confidence = min(total_score / 60, 1.0)

Usage

Basic Usage

Analyze the top 100 places (default):

python manage.py predict_place_events

Options

--limit <number>

Number of places to analyze (default: 100)

python manage.py predict_place_events --limit 50

--address <address_string>

Filter places by address

python manage.py predict_place_events --address "San Francisco, CA"
python manage.py predict_place_events --address "Oakland"

--place_id <uuid>

Analyze a specific place by ID

python manage.py predict_place_events --place_id "123e4567-e89b-12d3-a456-426614174000"

--min_confidence <float>

Minimum confidence threshold to display results (default: 0.3)

python manage.py predict_place_events --min_confidence 0.5

--verbose

Show detailed prediction information including score breakdowns

python manage.py predict_place_events --verbose --limit 20

--update

Update places in the database with prediction results (adds to data_sources field)

python manage.py predict_place_events --update --limit 100

Example Commands

Find event venues in Portland with detailed output:

python manage.py predict_place_events --address "Portland, OR" --verbose --limit 50

Update top 200 places with predictions:

python manage.py predict_place_events --limit 200 --update

Analyze a specific venue:

python manage.py predict_place_events --place_id abc-123-def --verbose

High-confidence predictions only:

python manage.py predict_place_events --min_confidence 0.7 --limit 100

Output Format

Standard Output

✓ Fox Theater
Confidence: 65.0%
Score: 32.5
URL: https://vibemap.com/places/details/fox-theater

Verbose Output

✓ Fox Theater
Confidence: 68.0%
Score: 40.5
URL: https://vibemap.com/places/details/fox-theater
Address: 1807 Telegraph Ave

Score Breakdown:
keyword_score: 9.0
category_score: 2.5
vibe_score: 6.0
event_history_score: 15.0
event_platform_score: 8.0
Keywords: venue, live music, theater
Categories: Arts & Culture
Vibes: energetic, lively, nightlife, social
Past Events: 33
Event Platforms: Ticketmaster

Summary Statistics

============================================================
SUMMARY
============================================================
Total places analyzed: 100
Predicted to have events: 23
Percentage: 23.0%

Confidence breakdown:
High (>70%): 8
Medium (40-70%): 12
Low (<40%): 3
============================================================

Database Updates

When using the --update flag, the command adds prediction data to each place's data_sources field:

{
"type": "event_prediction",
"data_source_name": "ML Event Predictor",
"has_events_predicted": true,
"confidence": 0.65,
"score": 32.5,
"timestamp": "2025-12-04T18:45:37.000Z"
}

This allows you to:

  • Track prediction history
  • Filter places by prediction confidence
  • Compare predictions with actual event counts
  • Improve the model over time

Use Cases

1. Discovery of Event Venues

Identify potential event venues that haven't been tagged yet:

python manage.py predict_place_events --min_confidence 0.6 --limit 500

2. Data Quality Improvement

Find places that should have events but don't:

python manage.py predict_place_events --verbose --update

3. Regional Analysis

Understand event venue distribution in specific areas:

python manage.py predict_place_events --address "Brooklyn, NY" --verbose

4. Targeted Marketing

Identify venues for event promotion campaigns:

python manage.py predict_place_events --min_confidence 0.7 --update

Model Tuning

You can adjust the prediction model by modifying the EventPredictor class in the command file:

class EventPredictor:
def __init__(self):
self.keyword_weight = 3.0 # Adjust keyword importance
self.category_weight = 2.5 # Adjust category importance
self.vibe_weight = 1.5 # Adjust vibe importance
self.has_events_weight = 10.0 # Adjust historical event importance
self.threshold = 5.0 # Minimum score for prediction

You can also modify the keyword lists, categories, and vibes used for matching.

Future Improvements

Potential enhancements to the prediction model:

  1. Machine Learning Model: Train a classification model using scikit-learn or similar
  2. NLP Integration: Use the existing Nyckel API for text classification
  3. Temporal Features: Consider day of week, seasonality, and trends
  4. Social Media Signals: Analyze Instagram/Facebook activity
  5. Website Analysis: Scrape venue websites for event calendars
  6. User Feedback: Incorporate manual verification to improve accuracy

Integration with Existing Commands

This command complements existing NLP and classification commands:

  • nlp_categories: Categorizes places using NLP
  • sync_vibes: Updates vibes for places
  • check_events: Validates event data
  • check_listings: Validates place data

Performance

The command is optimized for batch processing:

  • Filters out closed, duplicate, and non-public places
  • Only processes places with descriptions
  • Uses database indexes for efficient querying
  • Can process 100 places in ~10 seconds

Troubleshooting

No predictions found:

  • Check that places have descriptions
  • Lower the --min_confidence threshold
  • Verify places aren't filtered out (closed, duplicate, etc.)

Low confidence scores:

  • Places may lack sufficient text data
  • Categories may not match event-related categories
  • Consider enriching place descriptions

Database update errors:

  • Ensure you have write permissions
  • Check database connection
  • Verify data_sources field accepts JSONField data