2.5. Exercises and Projects#

Exercise 2.1 (Handwritten example)

Consider the 1-dimensional data set shown below.

Table 2.1 Dataset#

\(x\)

1.5

2.5

3.5

4.5

5.0

5.5

5.75

6.5

7.5

10.5

\(y\)

\(+\)

\(+\)

\(-\)

\(-\)

\(-\)

\(+\)

\(+\)

\(-\)

\(+\)

\(+\)

Please use the data to compute the class of \(x=5.5\) according to \(k=1\), \(3\), \(6\) and \(9\). Please compute everything by hand.

Exercise 2.2

Please download the titanic dataset from here. This is the same dataset from what you dealt with in Chapter 1 Exercises. Therefore you may use the same way to prepare the data.

Please analyze the dataset and build a k-NN model to predict whether someone is survived or not. Note that you have to pick k at the end.