Back
ExamFull examExam paper only

16 06 2022 E T LAB

Full exam for Numerical Analysis for Machine Learning in the Mathematical Engineering degree programme at Politecnico di Milano. The document covers: Course: Numerical Analysis for Machine Learning Prof. E. Miglio - Jume 16th 2022 Duration of the exam: 2.5 hours. Exercise 1 We consider a database containing the temperature in four corners of a room as a function of time. Each row of the matrix A refers to a time and each

Numerical Analysis for Machine LearningFull exam

Document information

What's included in this study material

Full exam for Numerical Analysis for Machine Learning in the Mathematical Engineering degree programme at Politecnico di Milano. The document covers: Course: Numerical Analysis for Machine Learning Prof. E. Miglio - Jume 16th 2022 Duration of the exam: 2.5 hours. Exercise 1 We consider a database containing the temperature in four corners of a room as a function of time. Each row of the matrix A refers to a time and each

Import quality: text was extracted directly from the original document.

Extracted content from the document

Representative passages recognised in different parts of the material. The full extracted text remains available to search, while this compact preview makes the page easier to read.

Page 1

Course: Numerical Analysis for Machine Learning Prof. E. Miglio - Jume 16th 2022 Duration of the exam: 2.5 hours. Exercise 1 We consider a database containing the temperature in four corners of a room as a function of time. Each row of the matrix A refers to a time and each column represents the temperature in a corner of the room. import pandas as pd import numpy as np import matplotlib.pyplot as plt data = pd.read_csv(’https://openmv.net/file/room-temperature.csv’) labels = [’FrontLeft’, ’FrontRight’, ’BackLeft’, ’BackRight’] A = data.to_numpy()[:,1:].astype(np.float64) A -= 273.15 #from Kelvin to Celsius 1. How many samples and features are there in the dataset ? 2. Plot the values over time of the temperature in the four corners of the room. From the figure, what can you tell about the potential for dimensionality reduction of the dataset? 3. Perform PCA on the dataset by means of the SVD decomposition. Then, plot the trend of the fraction of the ”explained variance”: ∑k i=1σ2 i∑q i=1σ2 i ; 4. Print the four principal directions. 5. By using the principal directions computed above, perform dimensionality reduction using only the first k principal directions. Repeat the exercise for k = 1, 2, 3. 6. Plot the values over time of the temperature in the four corners of the room, obtained from the recon- structions of rank 1, 2 and 3 obtained above. 7. Comment on the results of points 3,4 and 6. Exercise 2 Consider the Boston dataset contained in scikit-learn: import numpy as np from sklearn.datasets import load_boston from sklearn.model_selection import train_test_split # Load the Boston housing dataset. X_boston, y_boston = load_boston(return_X_y=True) # Split into 60% training, 20% validation and 20% test. X_boston_tr, X_rest, y_boston_tr, y_rest = \…

Preview

First page of the document.

First page: 16 06 2022 E T LAB