Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 59 pages
Exam (elaborations)

COS4852 Assignment 3 2026 Machine Learning Year Module 2026

Document preview thumbnail
Preview 4 out of 59 pages

A clear, well-structured assignment with accurate answers and explanations to help you understand the material and complete your work with confidence. Work with us and give yourself a better chance of success.

Content preview

UNIVERSITY OF SOUTH AFRICA (UNISA)
College of Science, Engineering and Technology







Machine Learning Assignment
Semester 2 – 2026








Module Code: COS4852

Module Name: Machine Learning

Assignment No.: 03

Semester: Semester 2, 2026




Submitted in partial fulfilment of the requirements for Machine Learning
at the University of South Africa.

, Question 1

Consider the following dataset consisting of 10 instances in (x,y) coordinates, classified as Class A,
B, or C:

A1 : (4.0,4.0) - Class A
A2 : (4.3,2.5) - Class A
A3 : (6.5,3.0) - Class A
A4 : (6.0,4.5) - Class A
B1 : (7.5,8.5) - Class B
B2 : (6.5,6.8) - Class B
B3 : (7.5,6.0) - Class B
B4 : (5.0,6.5) - Class B
B5 : (6.7,5.0) - Class B C1 :
(3.5,2.5) - Class C

A new instance V of unknown class is at (-5.0, -5.0).


a) Draw an accurate diagram to show all the instances in the (x,y)-space. Clearly annotate your
diagram.

b) Use the KNN-algorithm to determine the class of V . First use the Euclidian distance measure
with k = 5. Show all your steps, distance calculations, the order of instances and the process
of selecting the class for the unknown instance V .

c) Repeat the process of finding the class of V using the Manhattan distance measure. Show all
your steps, distance calculations, ordering of instances, and the process of selecting the class.

BONUS Use your diagram to show the full extent of the areas covered by each distance measure that
includes the 5 nearest neighbours from the new intances V . Think carefully how Euclidian and
Manhattan distances are defined in 2D space.


[100]

,UNISA | COS4852 Machine Learning: KNN Classification



Question 1: K-Nearest Neighbour Classification

The dataset consists of ten labelled instances belonging to Class A, Class B, or Class C, to-
gether with one unlabelled instance V at (−5.0, −5.0) whose class must be determined using
the K-Nearest Neighbour (KNN) algorithm.


1(a) Diagram of the Instances in (x, y)-Space


The coordinates of all instances, including the unknown instance V , are summarised below
before being plotted.

Table 1: Coordinates and class labels of all instances
Instance x y Class
V -5.0 -5.0 Unknown
A1 4.0 4.0 A
A2 4.3 2.5 A
A3 6.5 3.0 A
A4 6.0 4.5 A
B1 7.5 8.5 B
B2 6.5 6.8 B
B3 7.5 6.0 B
B4 5.0 6.5 B
B5 6.7 5.0 B
C1 3.5 2.5 C


The scatter plot below places every instance on the same set of axes. V lies far to the lower-
left of all ten labelled points, so its nearest neighbours are simply whichever labelled points
sit closest to the bottom-left corner of the plotted space.


1(b) KNN Classification of V Using Euclidean Distance (k = 5)


The Euclidean distance between V = (−5, −5) and any point P = (xP , yP ) is


p
dE (V, P ) = (xP + 5)2 + (yP + 5)2 .


Applying this formula to each of the ten instances gives the following distances. The calcula-
tion for A1 is shown in full as an example, and the same procedure is used for the remaining
nine points.




Page 1 of 7

, UNISA | COS4852 Machine Learning: KNN Classification


y B1 Class A
8 Class B
B2 Class C
B4
B3 V (unknown)
6
A4
B5
A1
4

A3
C1 A2
2

x
−6 −4 −2 2 4 6 8

−2


−4
V


−6


Figure 1: All ten labelled instances and the unknown instance V plotted in (x, y)-space



p √ √
dE (V, A1) = (4 + 5)2 + (4 + 5)2 = 81 + 81 = 162 = 12.728.



p √ √
dE (V, A2) = 9.32 + 7.52 = 86.49 + 56.25 = 142.74 = 11.947.



p √ √
dE (V, A3) = 11.52 + 82 = 132.25 + 64 = 196.25 = 14.009.



p √ √
dE (V, A4) = 112 + 9.52 = 121 + 90.25 = 211.25 = 14.534.



p √ √
dE (V, B1) = 12.52 + 13.52 = 156.25 + 182.25 = 338.5 = 18.398.



p √ √
dE (V, B2) = 11.52 + 11.82 = 132.25 + 139.24 = 271.49 = 16.477.



p √ √
dE (V, B3) = 12.52 + 112 = 156.25 + 121 = 277.25 = 16.651.


Page 2 of 7

Connected book
 image
Peter Flach Machine Learning
Publisher: 2012-09-20 ISBN: 9781107422223 Edition: 1

Document information

Uploaded on
July 29, 2026
Number of pages
59
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$23.91

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
LectureLab
3.6
(86)
Sold
683
Followers
188
Items
1553
Last sold
1 week ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions