An end-to-end streaming dynamic pricing and congestion-rerouting engine built from scratch using Python, NumPy, Pandas, Pathway, and Bokeh (Summer Analytics 2025 Capstone — Consulting & Analytics Club × Pathway).
Static parking tariffs cause peak-hour overcrowding and off-peak underutilization. This system ingests chronologically ordered telemetry across 14 urban parking lots (18,368 raw records spanning 73 days), normalizes multi-factor demand signals, incorporates spatial competitor pricing via Haversine proximity, and emits smooth, bounded prices ($5.00–$20.00 from a $10.00 base) through a real-time Pathway streaming pipeline.
dataset.csv (18,368 rows, 14 lots)
│
▼ Data Audit & Cleaning (dedup 86 keys, clip 241 >100% occ, encode 'cycle', flag GPS outlier)
│
├──► Model 1: Daily-Reset Linear Baseline (Occupancy / Capacity)
├──► Model 2: Tanh-Normalized Demand + EMA Smoothing (η = 0.45)
├──► Model 3: Haversine Spatial Competition (1.0 km) + Rerouting Engine
│
▼ Pathway Real-Time Simulation (pw.demo.replay_csv → @pw.udf → 30-min tumbling windows)
│
▼ Interactive Bokeh Dashboards (Multi-model comparison, cluster competition, streamed market avg)
- Data Quality & Anomaly Handling: Cleaned
18,368→18,282unique(lot, timestamp)records by resolving86duplicate timestamp rows, clipping241over-capacity readings (>100%utilization), encoding an undocumentedcyclevehicle class (1,762rows), and isolating a~1,561 kmGPS coordinate outlier (BHMMBMMBX01) so spatial pricing never degrades. - Price Smoothness & Volatility Control: Applying
tanhdemand normalization with per-lot EMA smoothing (η = 0.45) reduced step-to-step price jitter by44.1%($1.067→$0.596/step), and spatial competition in Model 3 further reduced it to46.5%total ($0.571/step). - Demand Elasticity & Revenue Impact: Model 3 differentiates off-peak (
$7.44avg at<40%occupancy) from peak congestion ($14.10avg at>=80%occupancy), delivering a+7.64%simulated revenue proxy lift (+8.58%in Model 2) over static$10.00pricing while keeping the overall mean price anchored at$10.11. - Automated Congestion Rerouting: Triggered
1,639real-time reroute recommendations (9.0%of intervals) when a lot reached>=85%occupancy while cheaper nearby lots (<=1.0 km) had available capacity, saving drivers$9.55on average (up to$11.23). - Real-Time Streaming Pipeline: Replayed globally time-ordered sensor events through Pathway (
pw.demo.replay_csv,@pw.udf,pw.temporal.tumbling30-minute aggregations, andpw.io.csv.write) with persisted Bokeh visualizations.
| Model | Mean Price | Std Dev | Range | Off-Peak (<40%) |
Peak (>=80%) |
Revenue Lift vs. $10 |
|---|---|---|---|---|---|---|
| Static Baseline | $10.00 |
$0.00 |
[$10.00, $10.00] |
$10.00 |
$10.00 |
0.00% |
| Model 1 (Linear) | $13.30 |
$2.79 |
[$10.00, $20.00] |
— | — | — |
| Model 2 (Demand + EMA) | $10.04 |
$3.48 |
[$5.00, $17.21] |
$6.78 |
$15.09 |
+8.58% |
| Model 3 (Competitive + Reroute) | $10.11 |
$2.93 |
[$5.07, $17.06] |
$7.44 |
$14.10 |
+7.64% |
src/pricing_engine.py— Modular data-cleaning, Haversine spatial matrix, Models 1–3, and evaluation metrics library.tests/test_pricing.py— Unit and full-dataset integration tests (pytest).dynamic_pricing_capstone.ipynb— Complete Google Colab notebook with data audit, Models 1–3, Bokeh charts, and Pathway streaming simulation.results/pathway_pricing_output.csv— Streamed real-time per-lot price predictions emitted by Pathway (1,736events).results/pathway_market_window.csv— Pathway 30-minute tumbling window market averages (97intervals).requirements.txt— Python dependencies (with Linux/Colab platform marker forpathway).dataset.csv— Historical telemetry dataset across14urban parking lots (73days).problem statement.pdf— Original project specification.LICENSE— MIT License.
- Upload
dynamic_pricing_capstone.ipynbanddataset.csvto Google Colab (Linux runtime required forpathway). - Run Runtime → Run all; missing packages (
pathway,bokeh) are installed automatically in Cell 1. - Inspect the interactive Bokeh comparisons and the streamed
pathway_pricing_output.csv/pathway_market_window.csvoutputs.
pip install -r requirements.txt
pytest -v