Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Document preview thumbnail
Vista previa 4 fuera de 59 páginas
Examen

COS4852 Assignment 3 2026 Machine Learning Year Module 2026

Document preview thumbnail
Vista previa 4 fuera de 59 páginas

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.

Vista previa del contenido

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

Libro relacionado
 image
Peter Flach Machine Learning
Editorial: 2012-09-20 ISBN: 9781107422223 Edición: 1

Información del documento

Subido en
29 de julio de 2026
Número de páginas
59
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas
$23.91

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
LectureLab
3.6
(86)
Vendido
683
Seguidores
188
Artículos
1553
Última venta
1 semana hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes