Name the GPS k-means areas by their marquee ride

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>
This commit is contained in:
wes
2026-05-27 19:35:42 -04:00
co-authored by Claude Opus 4.7
parent 53109bc7fe
commit e65d1c796c
+11 -2
View File
@@ -170,8 +170,10 @@ def compute_pca():
loadings = loadings.join(meta) loadings = loadings.join(meta)
# Spatial "areas" from GPS alone — k-means on standardized lat/lon, the same # Spatial "areas" from GPS alone — k-means on standardized lat/lon, the same
# 5 clusters the write-up uses. Label the one whose rides lean most negative # 5 clusters the write-up uses. Names are derived, not hard-coded to a
# on PC2 as Kiddieland so the colors read in plain English. # cluster index, so they survive re-clustering as the history grows:
# - Kiddieland = the cluster whose rides lean most negative on PC2.
# - the rest are named for the marquee ride that lands in each.
located = loadings.dropna(subset=["lat", "lon"]) located = loadings.dropna(subset=["lat", "lon"])
if len(located) >= 5: if len(located) >= 5:
km = KMeans(n_clusters=5, n_init=10, random_state=0).fit_predict( km = KMeans(n_clusters=5, n_init=10, random_state=0).fit_predict(
@@ -179,6 +181,13 @@ def compute_pca():
area = pd.Series(km, index=located.index) area = pd.Series(km, index=located.index)
kiddie = loadings.loc[area.index].assign(a=area).groupby("a")["PC2"].mean().idxmin() kiddie = loadings.loc[area.index].assign(a=area).groupby("a")["PC2"].mean().idxmin()
names = {kiddie: "Kiddieland"} names = {kiddie: "Kiddieland"}
anchors = [("phoenix", "The Woodies"),
("impulse", "The Grand Midway"),
("flying_turns", "Flying Turns Grove"),
("giant_wheel", "Giant Wheel Corner")]
for ride, label in anchors:
if ride in area.index:
names.setdefault(area[ride], label) # don't overwrite Kiddieland
loadings["area"] = area.map(lambda a: names.get(a, f"Area {a + 1}")) loadings["area"] = area.map(lambda a: names.get(a, f"Area {a + 1}"))
else: else:
loadings["area"] = "Untagged" loadings["area"] = "Untagged"