Distances and predictions
Task 7 · worked step 4
Use all six feature positions to calculate distance to training students. Choose the smallest distance, then take that training student's label.
Lab 4 PDF pp. 6–7 · Task 7
Your task
Compare T1, T2 and N1 separately with S1–S4. Use the stated tie rule if needed. Score only T1 and T2, whose outcomes are known.
Evidence to include
Neighbours come from training; scores need known labels.
Worked example and code
Try the task in the PDF first, then compare your working below. Run the code in your own Python notebook.
Open Lab 4 instructions (PDF)| Candidate | Distance to S1 / S2 / S3 / S4 | Nearest and prediction |
|---|---|---|
| T1 | 0.295008 / 1.550604 / 3.752087 / 3.340821 | S1; Withdraw |
| T2 | 4.114310 / 2.988968 / 1.486327 / 2.316751 | S3; Stay |
| N1 | 2.539302 / 1.920892 / 2.271516 / 1.600129 | S4; Stay |
T1 and T2 are both correct: observed test error 0/2=0%, accuracy 2/2=100%. Two held-out cases provide very weak evidence about reliable performance. N1's prediction is reported separately; its unknown true outcome cannot be scored. Do not tune the rule after inspecting these test outcomes.
The final vector includes one-hot coordinates, not just the three scaled numerical values. A tie is broken by smaller training ID as specified. ID itself is never a distance coordinate.
Practice problems
Supplementary study questions on the lecture concepts — not verbatim exam questions. Each answer counts toward spaced review.
1. Conceptual understanding
Definitions and distinctions.
The combined lab correctly predicts both T1 and T2. What may be reported?
In the supplied combined lab, which neighbour predicts N1?
2. Application
Apply the concept to a case or calculation.
Which training student is closest to T1 in the supplied six-feature calculation?
Which training student is closest to T2?
3. Interpretation and limitations
Evaluate assumptions and justify conclusions.
Which denominator belongs in the reported combined-lab test error?
If two training records are equally close, what rule does this lab use?
Explain it in writing
Self-checked, not marked. Write a few sentences, then compare with the example answer. Your writing is saved as you type.
Show an example answer
It describes only two held-out test cases. State 2/2 correct and explain that such a small sample gives weak evidence about reliable future performance.
Check: did you answer the question, use evidence or working, and avoid claiming more than the evidence supports?
Show an example answer
They are part of the specified six-position vector. Omitting them changes the method and can change which training student is closest.
Check: did you answer the question, use evidence or working, and avoid claiming more than the evidence supports?
Saved only in this browser. This note doesn’t fill in the downloaded notebook; “reviewed” is a personal checklist, not a grade.