Cos4852 2023 Assignment 1
Cos4852 2023 Assignment 1
Machine Learning
COS4852
Year module
School of Computing
CONTENTS
This document contains the questions for Assignment 1 for COS4852 for 2023.
university
Define tomorrow. of south africa
CONTENTS
1 INTRODUCTION ..................................................................................................................5
2 Assignment 1 ......................................................................................................................5
2
COS4852/A1
LIST OF FIGURES
3
LIST OF TABLES
4
COS4852/A1
1 INTRODUCTION
This document discusses the questions in Assignment 1 for COS4852 for 2023.
Each question (except Q1 = 10 marks) will be assigned a mark out of 100 and the total mark for the
assignment is then calculated out of (10 + (5 × 100)) = 510.
When we mark the question we want to see that YOU understand the work. Simply copying or
regurgitating other peoples’ work (from the web, previous solutions, other students’ work) does not
show that YOU understand the work. Show ALL your assumption, definitions, variables, and full
calculations.
2 Assignment 1
Question 1
Give the complete URL where you found these textbooks, as well as the file size of the PDF you’ve
downloaded.
5
Question 2
Read Nilsson’s book, Chapter 2. Summarise the chapter in 2-4 pages in such a way that you can
show that you thoroughly understand the concepts described there. Use different example functions
from the ones in the book to show that you understand the concepts.
6
COS4852/A1
Question 3
Read Chapter 5 of Welling’s book. Do some research on the k-nearest neighbour classification
algorithm and write a 2-page report on how the algorithm works. Your report should include a
detailed example, with all calculations shown.
7
Question 4
Let X be an instance space consisting of points in the Euclidian plane with integer coordinates (x, y),
with positive and negative instances as shown in Figure 1.
y
10 Positive instances:
(5, 5)
(−6, 4)
(−3, −4)
(2, −4)
5
Negative instances:
(−1, 2)
(−2, 0)
(6, 7)
x (8, −8)
-10 -5 5 10
-5
-10
Let H be the set of hypothesesp consisting of origin-centered donuts. Formally, the donut hypothesis
has the form h ← ha < x + y 2 < bi, where a < b and a, b ∈ Z ( Z is the set of non-negative
2
An example of a donut hypothesis is h ← h2, 5i and is shown in Figure 2. Notice that this hypothesis
does not explain the data correctly, since there are both positive and negative instances inside the
donut and neither does the donut contain all the positive or all the negative instances, exclusively.
(a) What is the S-boundary set of the given version space? Write out the hypotheses in the form
given above and draw them.
(b) What is the G-boundary set of the given version space? Write out the hypotheses in the form
given above and draw them.
(c) Suppose that the learner now suggests a new (x, y) instance and asks the trainer for its
classification. Suggest a query guaranteed to reduce the size of the version space, regardless
of how the trainer classifies it. Suggest one that will not reduce the size of the version space,
regardless of how the trainer classifies is. Explain why in each case.
8
COS4852/A1
10
x
-10 -5 5 10
-5
-10
9
(d) The donuts are one of many possible hypothesis spaces that could explain this data set.
Propose one alternative hypothesis space and explicitly define its parameters as was done
using a and b for the donuts. Choose an instance from your hypothesis space that separates
the given data. Write out this hypothesis and sketch it.
• http://cse-wiki.unl.edu/wiki/index.php/Concept_Learning_and_the_General-to-Specific_
Ordering
• http://www.cs.northwestern.edu/~pardo/courses/mmml/lectures/NU%20EECS%20349%20Fall%
2009%20topic%201%20-%20version%20spaces.pdf
• http://www.ccs.neu.edu/home/rjw/csg220/lectures/version-spaces.pdf
10
COS4852/A1
Question 5
(a) f1 (A, B) = ¬A ∧ B
(b) f2 (A, B, C) = [A ∧ B] ∨ C]
(c) f3 (A, B) = A Y B
(d) f4 (A, B, C, D) = [A ∨ B] ∧ [C ∨ D]
Read: https://www.geeksforgeeks.org/difference-between-graph-and-tree/
The symbol Y represents the Boolean operator for XOR (exclusive-or). For this exercise you do not
need to do the Gain or Entropy calculations. There is a direct mapping between a Boolean function
and its corresponding binary decision tree. The binary decision tree can usually by simplified as
well to produce a simpler, more compact tree. Do not just write down the final, simplified tree. Show
how you do the simplification.
Here are resources you could consult on this topic - they are also a good introduction to material for
the next question:
• https://www.cs.cmu.edu/~fp/courses/15122-f10/lectures/19-bdds.pdf
• http://cs.nyu.edu/~dsontag/courses/ml12/slides/lecture11.pdf
11
Question 6
Use the ID3 algorithm to construct a decision tree for the data in Table 1. Show all your calculations,
including all the steps of the Gain and Entropy calculations. Show the formulas that you use. Clearly
explain your choices.
A B C D f5
F F F F no
F F F T no
F F T F no
F F T T no
F T F F no
F T F T yes
F T T F yes
F T T T yes
T F F F no
T F F T yes
T F T F yes
T F T T yes
T T F F no
T T F T yes
T T T F yes
T T T T yes
Here are some resources you could consult on this topic (focus on the ID3 algorithm):
• https://medium.com/deep-math-machine-learning-ai/chapter-4-decision-trees-algorithms-
• https://www.cise.ufl.edu/~ddd/cap6635/Fall-97/Short-papers/2.htm
• http://www.ke.tu-darmstadt.de/lehre/archiv/ws0809/mldm/dt.pdf
• https://cis.temple.edu/~ingargio/cis587/readings/id3-c45.html
12
COS4852/A1
© UNISA 2023
13