Instructor notes: Lecture 5 practical (Smart clustering of cherry blossom photos)

Tested with Python 3.12, scikit-learn 1.8, ipywidgets 8.1: the whole notebook runs top to bottom in about 30 s (a clustering takes about 0.3 s; the interactive tool about 1.5 s per click). All numbers below are from that run.
DBSCAN results are deterministic; k-means numbers (Part 2) and the MDS colours can differ slightly with other scikit-learn versions.

Timing (60 minutes)

StageContentmin
1Look at the data (map, season)5
2Distance for space and time: flat earth vs great circle, radii, relative distances, combine rule, checkpoint10
3First run: 25 km, 7 days, N = 75
4Parameter sensitivity: interactive tool, sweeps12
5optional Same K, same groups? (Jaccard recurrence)8
6Assess and revise: round 2 (space only)12
7Season by place and year8
8Wrap-up, one written paragraph3

Differences from the earlier version of this practical

Answer key, Part 1

Answer key, Part 2 (k-means, min-max scaling, seed 10, 10 restarts)

Colours (Part 2 vs Part 1)

Wrap-up recommendations (end of Part 2)

Eight recommendations from https://geoanalytics.net/and/SmartIterator/ (Practical Recommendations), each mapped to the stage where students did it. Recommendation 6 is worded differently from the page: the page suggests that a silhouette fluctuation above 0.02 across seeds signals instability. In the paper's EU example the silhouette varied by only 0.012 over 30 seeds while the groups agreed only moderately (median adjusted Rand index 0.53), so the notebook says: look at the score and at the groups. In this notebook's weekly data the silhouette does swing with the seed (0.50 to 0.69 at K = 15).

Part 3 (audit)

Categories are those of the course manual. Passage 1 (weekly counts): sycophancy, overstated certainty, unacknowledged confounds, erased uncertainty, fabricated or unseen detail, causal/prescriptive. Passage 2 (photos): sycophancy, overstated certainty, false precision, unacknowledged confounds, erased uncertainty, causal/prescriptive.
Marking is not needed: the checklist reveals its own analysis. Collect the rewrites and the synthesis paragraph if you want to see understanding.

Likely misconceptions

Data and privacy

cherry_photos.csv was derived from public Flickr photo metadata. Only longitude, latitude and the time of taking were used; no user names, ids, titles, tags or URLs. Coordinates were projected to km (Albers equal-area, standard parallels 29.5 and 45.5, origin 96 W, 23 N); t_days is days since 2007-01-01. The photo set includes some Canadian places (Vancouver, Toronto). The 3- and 6-year files of the earlier practical are subsets of this file.
weekly_counts_by_regions.csv holds aggregated counts. The base map is made from Natural Earth data (public domain).

Direct links to the data sets: ?ds=cherry-photos and ?ds=cherry-weeks (for example demo/?ds=cherry-photos).
Agreement: the demonstrator uses the same distance recipe (great-circle distance in km, optional time difference), so the first run of the photos gives the same 106 clusters and 30.2 % noise as the notebook. Do not expect every number to match across implementations: libraries, random seeds and floating-point details differ (for example, the demonstrator's k-means for Part 2 uses 5 random starts per run, the notebook 10, so partitions at high K can differ slightly).
Stage 4 sweeps = the first three sweeps of Cherry blossom photos; round 2 = the fourth sweep, or Explore with Items: members of the clusters of the active iteration and time switched off.
Part 2 = Cherry blossom photos per week (calendar, box plots, transition view, Order runs for the seed sweep).
The demonstrator's silhouette is computed on a reference sample, so values differ slightly from the notebook.

Possible extensions

Progressive refinement of loose clusters (lecture slide 65); HDBSCAN as an alternative to DBSCAN; a year filter for Round 1 (the 3- and 6-year files of the earlier practical).