New dashboard tab that rates current park crowding:
- Tiers: k-means on park-wide mean wait yields 4 ordinal levels
("Walk right on" / "Pleasant" / "Packed" / "What were you
thinking?!"), with the rare 0.6% zoo tail isolated as its own
tier rather than buried in a quartile.
- Board-reading model: multinomial LR on per-ride waits -> tier.
Drives the live gauge (current avg wait + predicted tier +
confidence + class-probability bar). Near-perfect by construction
-- honest framing baked into the model card.
- Calendar-forecast model: LR on hour/dow/month/weekend -> tier,
evaluated with GroupKFold by date to avoid same-day leakage.
Drives the "expected vs actual" verdict for the current moment.
- Bellwether rides bar (top tier coefficients) and a confusion-
matrix expander tell the honest story: forecast barely beats
baseline on everyday tiers, but pins the zoo tier nearly 100% --
because Knoebels' worst crowds are locked to specific October
festival weekends. "The chaos has a schedule."
Implementation notes: trained models cached via st.cache_resource
(6h), live snapshot fetched separately on a 5-min ttl. Context
features use a fixed column set so live inference always aligns.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- compute_pca now fits 4 components; PC4 added to PC_LABELS/PC_BLURB
("off-peak spread vs headliner pull", ~5% variance, framed as
diminishing returns).
- "Read an axis" loadings explorer gains PC4.
- The behavioral-map scatter becomes interactive: pick any two
components for the X/Y axes, and color by category tag, spatial
area, or any component's loading (continuous RdBu, symmetric).
- Headline caption pinned to evr[:3] so "3 axes = 60%" stays true;
the by-hour clock stays PC1-3 to preserve the three-axes story.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replace the "Area N" fallbacks with derived names: Kiddieland
(lowest mean PC2) plus The Woodies / The Grand Midway / Flying
Turns Grove / Giant Wheel Corner, each keyed off the headline
ride that lands in the cluster so the labels survive re-clustering
as the wait history grows.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two spin/zoom Plotly scatter_3d sub-tabs in the PCA tab:
- Rides in PC1xPC2xPC3 (loadings), color by category / GPS
k-means area / PC1 busyness. Adds GPS k-means areas to
compute_pca(), auto-labeling the lowest-PC2 cluster Kiddieland.
- Moments in PC1xPC2xPC3 (per-snapshot scores), color by hour /
day-of-week / weekend / month, sampled to 15k points if larger.
Pin numpy in requirements (now imported directly).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replace the local records.json read with a two-step Occasio fetch
(install + data zip), then upsert Items and Categories into the
knoebels schema with ON CONFLICT (_id) DO UPDATE so re-runs refresh
in place. Also brings DB credentials in line with attractions_api_logger.py
(env vars, default host 192.168.88.9), drops dead helpers, and uses a
single shared connection.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Open one psycopg2 connection in main() and pass it through pull_data_and_log
and log_to_database. Previously each landing-zone insert opened its own
connection (3-4 handshakes per invocation); now everything runs in a single
session and the three LZ writes share one transaction.
Other cleanups:
- Replace bare `except:` blocks around attraction-field reads with .get()
- Drop the unused col_names computation in the old generic_query
- Move module-level driver code under `if __name__ == "__main__":`
- Parse park_opens / park_closes once instead of three times
- Name columns explicitly in the park-hours query (was SELECT *)
- Use `datestamp` (date column) for the today-freshness check rather
than reading .date() off the open timestamp
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Move DB host/user/password, Discord webhook, and log path to env vars
so the script can be deployed via Docker compose. Discord notifications
are now skipped silently when DISCORD_WEBHOOK is unset (the old
hardcoded webhook is removed pending rotation). Adds Dockerfile,
docker-compose.yml, requirements.txt, .env.example, and .gitignore for
the cyrion deployment.