Weekly exercises

Here you find the weekly exercises for the coming week, as well as an overview of exercises for past weeks. The week number refers to when the exercises will be discussed in the exercise class.

To learn the material well, it is important to spend time and make real efforts on trying to solve the exercises, preferably before the exercise class.

Some of the exercises are from the book James et al 2013: An Introduction to Statistical Learning, and will be referred to as ISLR

Note that the link to book website given in the book does not work any more; the new link is https://hastie.su.domains/ElemStatLearn/.

A link to the extra exercises is here.

Exercises the coming week

Week 10

Exercises from the book: 4.2 and 5.1

Exercises from ISLR: 4.9 and 4.14 (a-f)

Exam STK2100 2018: Problem 2

Extra exercise 6

Exercises for past weeks

Week 9

Exercises from the book: 4.1

  • Solution: Berit's suggested solution (similar to the one in the solution manual, but with an argument for why the solution is the eigenvector corresponding to the largest eigenvalue of \(\mathbf{W}^{-1} \mathbf{B}\))

Exercise from ISLR: 4.13 (without KNN)

Extra exercise: Modify the example with principal component (PC) regression in the R script r-code-week7.R, so that the numbers of principal components are selected through cross-validation instead of through separate training and test sets. Comment on the results.

?

Week 8

Exercises from the book: 3.2 and 3.29:

Exercises from ISLR: 3.9 a)-c) and e)-f)

  • Solutions: See here.

?

Week 7

Exercises from ISLR: 3.3. 3.4, 3.6, and 3.7

  • Solutions: See here.

Extra exercises 4 and 5 (you will need this: extra4.r)

?

Week 6

Exercises from ISLR: 3.8 and 3.5

Extra exercises (see link above): 1, 2 and 3?

?

Week 5

Exercises from the book: 2.7

  • Solutions: See the slides from the exercise session here. Alternatively, see pages 8-9 here, but note a few typos. In (a) for linear regression: \(\hat\beta\) should be \((X^TX)^{-1}X^Ty\) and not \(X(X^TX)^{-1}X^Ty\). For k-NN, a \(y_i\) is missing in the expression. In (b) you should add and subtract \( \mathrm{E}_{\mathcal{Y}|\mathcal{X}}[\hat{f}(x_0)] \) instead of \( \mathrm{E}_{\mathcal{Y}|\mathcal{X}}[f(x_0)] \), and similarly with the unconditional expectation in exercise (c).

Exercises from ISLR: 2.1, 2.2, and 2.8 (see the webpage for the book for downloading data; the easiest alternative is to install the ISLR library (through the command install.packages("ISLR")), make the library available (through the library("ISLR")), and then make the data available through data(College)).

?

Publisert 21. jan. 2026 12:56 - Sist endret 27. feb. 2026 15:04