Clustering
Instrument the two-cluster segmenter
Page 6 adds signals that distinguish bad input from component failure in the two-cluster customer segmenter.
1Learn the idea
Read
Emit stage signals
Instrument the two-cluster customer segmenter so a run records enough structure to debug offline: counts, latency if relevant, pass/fail of silhouette or inertia recorded, and a stable stage name. Redact secrets and raw credentials from every event.
Read
Emit and assert
runs=[[0,0,0,1,1,1],[1,1,1,0,0,0]]
def same_partition(a,b):
return all((a[i]==a[j])==(b[i]==b[j]) for i in range(len(a)) for j in range(len(a)))
print({'stable':same_partition(*runs),'runs':len(runs)})
Expected evidence: stage evidence for observability. Prefer JSON or structured text you can grep in CI over prose logs for clustering-basics.
Read
Lock signals with a regression test
Turn one historical failure—especially k larger than n—into a test that fails if the signal disappears for the two-cluster segmenter. Observability without a failing test is optional decoration; observability with a test is part of the clustering-basics artifact.
Read
Lab notebook: signal schema
Draft a three-field event for the two-cluster segmenter: stage, ok, and one domain field derived from silhouette or inertia recorded; centers have finite values. Add fixture_id or docs_version when content can change. Explicitly list fields that must never appear (tokens, passwords, raw prompts) because joining cluster IDs back to raw emails in an unsecured export is in scope for this lab.
Wire one assertion that fails if the two-cluster segmenter event is missing after a run. Observability that cannot fail a test will not survive contact with a busy clustering-basics repository.
Read
Worked judgment
Imagine a teammate opens only your event stream after a bad deploy. Could they tell whether small 2D customer matrix was wrong, whether k larger than n, or scaling skipped so one feature dominates returned, or whether joining cluster IDs back to raw emails in an unsecured export slipped through? If not, rename fields until those three stories are distinguishable.
Read
Why this stage matters for the two-cluster segmenter
At the testing and observability stage for clustering-basics, the job is narrower than finishing a product demo. You are creating one progressive evidence piece about small 2D customer matrix that later pages inherit without redefining success. Keep that fixture small enough to inspect by hand, keep outputs copy-pasteable as text, and refuse to narrate this baseline as if it were a production SLA: random two-group assignment inertia for comparison.
For this page specifically, success looks like a structured event schema locked by a test while still centering the user decision to group customers by spend/visits without pretending clusters are ground-truth labels. If you cannot point to a file, command, or assertion that proves that for the two-cluster segmenter, stay on this page instead of advancing.
Go deeper
Before you start
Why this matters
Write the single log line or metric event that would tell you whether a bad result came from input vs implementation for the two-cluster segmenter. If your line could not tell them apart, redesign it before coding.
Related lessons
Check your understanding
Page assessment
Answer from memory. Completion is saved from this evidence, not from opening the next page.
All responses are required.