• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 23 pages
Exam (elaborations)

COS4852 Assignment 3 Machine Learning Year Module 2026

Document preview thumbnail
Preview 3 out of 23 pages

Get a clear, reliable assignment with accurate answers and useful explanations. Choose us to help you stay on track and work towards better results.

Content preview

UNIVERSITY OF SOUTH AFRICA
College of Science, Engineering and Technology


⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄⋄


COS4852: Machine Learning

Assignment 3 | 2026, Year Module


⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄⋄




COS4852
Module Code:
Machine Learning
Module Name:
Assignment 3 – 2026
Assignment:
Year Module
Module Type:
500 (5 questions × 100 marks)
Total Marks:




Submitted in partial fulfilment of the requirements for Machine Learning, UNISA 2026

,UNISA | COS4852 Machine Learning – Assignment 3



Question 1: K-Nearest Neighbours Classification


1(a) Plotting the instances in the (x, y)-space


The ten labelled instances and the unknown instance V are summarised below.

Table 1: Instances plotted in the (x, y)-space
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


10 y
Class A
B1
Class B
8 Class C
B2
B4 V (unknown)
B3
6
B5
A4
A1
4
A3
C1 A2
2
x
−8 −6 −4 −2 2 4 6 8
−2

−4
V
−6

−8

Figure 1: Instances plotted in the (x, y)-space, annotated by class


The important spatial observation is that V lies far to the lower-left of every labelled instance.
Therefore the nearest neighbours are determined entirely by which labelled points lie closest to
(−5, −5).




Page 2 of 23

, UNISA | COS4852 Machine Learning – Assignment 3



1(b) KNN classification of V using the Euclidean distance, k = 5


The Euclidean distance between two points is

p
dE (V, P ) = (xP − xV )2 + (yP − yV )2 .


Since V = (−5, −5), this becomes

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




p √ √
dE (V, A1) = (4 + 5)2 + (4 + 5)2 =
81 + 81 = 162 = 12.728
p √ √
dE (V, A2) = (4.3 + 5)2 + (2.5 + 5)2 = 86.49 + 56.25 = 142.74 = 11.947
p √ √
dE (V, A3) = (6.5 + 5)2 + (3 + 5)2 = 132.25 + 64 = 196.25 = 14.009
p √ √
dE (V, A4) = (6 + 5)2 + (4.5 + 5)2 = 121 + 90.25 = 211.25 = 14.534
p √ √
dE (V, B1) = (7.5 + 5)2 + (8.5 + 5)2 = 156.25 + 182.25 = 338.5 = 18.398
p √ √
dE (V, B2) = (6.5 + 5)2 + (6.8 + 5)2 = 132.25 + 139.24 = 271.49 = 16.477
p √ √
dE (V, B3) = (7.5 + 5)2 + (6 + 5)2 = 156.25 + 121 = 277.25 = 16.651
p √ √
dE (V, B4) = (5 + 5)2 + (6.5 + 5)2 = 100 + 132.25 = 232.25 = 15.240
p √ √
dE (V, B5) = (6.7 + 5)2 + (5 + 5)2 = 136.89 + 100 = 236.89 = 15.391
p √ √
dE (V, C1) = (3.5 + 5)2 + (2.5 + 5)2 = 72.25 + 56.25 = 128.5 = 11.336



Table 2: Euclidean distances from V , ascending order
Rank Instance (Class) Distance
1 C1 (C) 11.336
2 A2 (A) 11.947
3 A1 (A) 12.728
4 A3 (A) 14.009
5 A4 (A) 14.534
6 B4 (B) 15.240
7 B5 (B) 15.391
8 B2 (B) 16.477
9 B3 (B) 16.651
10 B1 (B) 18.398

For k = 5 the five nearest neighbours are C1, A2, A1, A3, A4, with classes C, A, A, A, A.
Counting the votes gives A = 4, B = 0, C = 1. Class A has the majority, so


V = Class A

Page 3 of 23

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
23
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$21.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.
BeeNotes
4.1
(40)
Sold
352
Followers
0
Items
1012
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