Assignment 3
Unique No.: 230456
Due Date: 20 August 2026
,How You Should Structure and Submit Assignments
Use this document both to check your own answers and as a model of the standard expected for future
assignment submissions. Before your next submission, make sure you do the following:
● Answer every sub-part (a, b, c, i, ii, iii …) separately and label it clearly — don't merge sub-parts into
one paragraph.
● Show every step of a calculation, not just the final number. Markers award marks for method, not
only the final answer.
● State the formula you are using before you substitute numbers into it.
● Draw diagrams neatly (by hand or using software), label axes, and mark every instance/point
referenced in the question.
● Where a question says 'prove it' or 'show that', explicitly state the conclusion in words after the
calculation — don't leave the marker to infer it.
● For coding questions, submit actual output/screenshots from code you ran yourself, not what you
expect the output to be.
● Round consistently (2–3 decimal places is usually sufficient) and keep units/labels consistent
throughout.
● Submit a single, clearly ordered PDF or Word document with question numbers as headings, in the
order they appear on the assignment paper.
The rest of this document works through the actual assignment (Machine Learning: KNN, Perceptrons, Neural
Networks, and hands-on coding) exactly the way a full-mark submission should look.
, Question 1 — K-Nearest Neighbours [100]
Dataset: A1(4.0,4.0), A2(4.3,2.5), A3(6.5,3.0), A4(6.0,4.5) — Class A; B1(7.5,8.5), B2(6.5,6.8), B3(7.5,6.0),
B4(5.0,6.5), B5(6.7,5.0) — Class B; C1(3.5,2.5) — Class C. New instance V = (5.0, 5.0).
a) Diagram
Figure Q1: All instances, V, and the k=5 neighbourhood boundaries for both distance measures (bonus part shown here
too).
b) Euclidean distance, k = 5
Formula: d(V,P) = √[(x_V − x_P)² + (y_V − y_P)²]
Instance Calculation Distance Class
A4 √[(5−6.0)²+(5−4.5)²] = √(1+0.25) 1.118 A
A1 √[(5−4.0)²+(5−4.0)²] = √(1+1) 1.414 A
B4 √[(5−5.0)²+(5−6.5)²] = √(0+2.25) 1.500 B
B5 √[(5−6.7)²+(5−5.0)²] = √(2.89+0) 1.700 B
B2 √[(5−6.5)²+(5−6.8)²] = √(2.25+3.24) 2.343 B
A3 √[(5−6.5)²+(5−3.0)²] = √(2.25+4) 2.500 A
A2 √[(5−4.3)²+(5−2.5)²] = √(0.49+6.25) 2.596 A
B3 √[(5−7.5)²+(5−6.0)²] = √(6.25+1) 2.693 B
C1 √[(5−3.5)²+(5−2.5)²] = √(2.25+6.25) 2.916 C
B1 √[(5−7.5)²+(5−8.5)²] = √(6.25+12.25) 4.301 B