

W06 / 2026-10-12 / 35 MIN / ENGLISH
PCA, clusters, and what geometry can establish
Classroom formative practice. This does not add a weekly graded assignment. The exercise time is included in class practice, not added after the three-hour meeting.
Before you start
- Use a CPU runtime. Save a personal copy or open the downloaded notebook in Jupyter.
- Run the included complete walkthrough first. Read its setup, definitions, and checkpoints.
- Predict before running each exercise cell; then change only the requested factor.
- Keep your actual outputs, configuration, explanation, and limitation. Free tools are sufficient.
TASK 1 / PREDICT - RUN - EXPLAIN
Read retained variance correctly
Run the PCA part of the worked notebook. Explain why two explained-variance ratios are not classification accuracies.
- Write your prediction in the notebook response field before running.
- Run the starter cell below after the worked walkthrough.
- Make the requested controlled change and record the configuration.
- Explain the mechanism using the actual output, not an invented result.
observations['task1']={'explained_variance_ratio':pca.explained_variance_ratio_.tolist(),'retained_fraction':float(pca.explained_variance_ratio_.sum())}
print(observations['task1'])Self-check: The ratios describe variation retained by this fitted representation. They do not supply semantic or causal labels.
TASK 2 / PREDICT - RUN - EXPLAIN
Vary the cluster count
Fit k=2,3,4 using training features only, and inspect test-space silhouette scores. Treat this as exploratory representation analysis, not supervised class recovery.
- Write your prediction in the notebook response field before running.
- Run the starter cell below after the worked walkthrough.
- Make the requested controlled change and record the configuration.
- Explain the mechanism using the actual output, not an invented result.
from sklearn.cluster import KMeans
from sklearn.metrics import silhouette_score
observations['task2']=[]
for k_demo in [2,3,4]:
fitted=KMeans(n_clusters=k_demo,n_init=10,random_state=2026).fit(Ztr)
assigned=fitted.predict(Zte)
observations['task2'].append({'k':k_demo,'silhouette':float(silhouette_score(Zte,assigned))})
print(observations['task2'])Self-check: Report actual scores. A larger silhouette is evidence about separation in this representation, not proof of meaningful physical categories.
TASK 3 / PREDICT - RUN - EXPLAIN
Rename clusters without changing membership
Permute the cluster IDs below. Compare pairwise co-membership before and after the renaming.
- Write your prediction in the notebook response field before running.
- Run the starter cell below after the worked walkthrough.
- Make the requested controlled change and record the configuration.
- Explain the mechanism using the actual output, not an invented result.
before=np.array([0,0,1,2,1,2]); after=np.array([2,2,0,1,0,1])
observations['task3']={'same_membership':bool(np.array_equal(before[:,None]==before[None,:],after[:,None]==after[None,:]))}
print(observations['task3'])Self-check: Co-membership is unchanged. Cluster numbers are identifiers rather than ordered physical quantities.
Completion checklist
- Three predictions and three explanations.
- One controlled change with its actual outcome.
- One limitation and a brief AI-use/checking disclosure, or "none".
- A downloaded W06-evidence.json, then a two-minute peer explain-back.
The notebook marks incomplete response records as drafts. Completing the fields is not proof that an explanation is correct.
The guided walkthroughs were previously executed. The new exercise extension cells have not yet been execution-tested for this revision. Agent exercises are deterministic simulations; no paid model or consequential external action is used.