Assignment #3_handout
Assignment #3_handout
This problem set is worth a total of 50 points, consisting of 3 theory questions and 1 programming
question. Please carefully follow the instructions below to ensure a valid submission:
• You are encouraged to work in groups of two students. Register your team (of 1 or 2 members) on
the CMS at least ONE week before the submission deadline. You have to register your team for
each assignment.
• All solutions, including coding answers, must be uploaded individually to the CMS under the
corresponding assignment and problem number. On CMS you will find FOUR problems under each
assignment. Make sure you upload correctly each of your solution against
Assignment#X − P roblem Y (where X- Assignment number and Y is the problem number) on
CMS. In total you have to upload THREE PDFs (theoretical problems) and ONE ZIP file
(programming problem).
• For each theoretical question, we encourage using LaTeX or Word to write your solutions for
clarity and readability. Scanned handwritten solutions will be accepted as long as they are clean
and easily legible. Final submission format must always be in a single PDF file per theoretical
problem. Ensure your name, team member’s name (if applicable), and matriculation numbers are
clearly listed at the top of each PDF.
• For programming question, you need to upload a ZIP file to CMS under
Assignment#X − P roblem 4. Each ZIP file must contain a PDF or HTML exported from Jupyter
Notebook and the .ipynb file with solutions. Make sure all cells in your Jupyter notebook contain
your final answers. For creating PDF/HTML, use the export of the Jupyter notebook. Before
exporting, ensure that all cells have been computed. To do this:
The submission should include your name, team member’s name, and matriculation numbers at the
top of both PDF/HTML and .ipynb file document.
• Finally, ensure academic integrity is maintained. Cite any external resources you use for your
assignment.
• If you have any questions follow the instructions here.
1 of 3
Elements of Machine Learning, WS 2024/2025
Prof. Dr. Isabel Valera and Dr. Kavya Gupta
Assignment Sheet #3: Generalization, Regularization and Beyond Linearity
2
n
X p
X p
X
yi − β0 − βj xij + λ βj2 (2.2)
i=1 j=1 j=1
(a) Discuss how the model coefficients (βj ) change as λ → 0 and as λ → ∞ in both Equation 2.1
and 2.2. (4 Points)
(b) If we have significantly more independent features than observations and want to perform
feature selection, which type of regularization method should we use? (Hint: L1 or L2 ?) What
value of λ should be considered i.e. small or large? (3 Points)
Pp
2. Suppose that yi = β0 + j=1 xij βj + ϵi , where ϵ1 , . . . , ϵn are independent and identically
distributed from a N (0, σ 2 ) distribution.
(a) Write out the likelihood for the data. (2 Points)
(b) Assume the prior for β : β1 , . . . , βp are independent and identically distributed according to a
double-exponential distribution with mean 0 and common scale parameter b, written as:
1 |β|
p(β) = exp − .
2b b
Write out the posterior for β in this setting. (2 Points)
(c) Show that the lasso estimate is the mode for β under this posterior distribution. (4 Points)
f (x) = β0 + β1 x + β2 x2 + β3 x3 + β4 (x − ξ)3+
is indeed a cubic regression spline, regardless of the values of β0 , β1 , β2 , β3 , β4 .
2 of 3
Elements of Machine Learning, WS 2024/2025
Prof. Dr. Isabel Valera and Dr. Kavya Gupta
Assignment Sheet #3: Generalization, Regularization and Beyond Linearity
f1 (x) = a1 + b1 x + c1 x2 + d1 x3
f2 (x) = a2 + b2 x + c2 x2 + d2 x3
f1 (x) = a1 + b1 x + c1 x2 + d1 x3 ,
n Z !
X
2 (3) 2
ĝ1 = arg min (yi − g(xi )) + λ [g (x)] dx ,
g
i=1
n Z !
X
2 (4) 2
ĝ2 = arg min (yi − g(xi )) + λ [g (x)] dx ,
g
i=1
In this assignment, you will work on selecting the best model using K-fold cross-validation. You will also
explore methods for selecting hyperparameters to enhance the generalizability of your trained models.
Please refer to the file assignment 3 handout.ipynb and only complete the sections marked in red and
missing codes denoted with #TODO. Once you have filled in the required parts, revisit submission
instructions to check how to submit it.
3 of 3