Back
ExamFull examExam paper only

19 01 2021 E T

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 - January 19th 2021 Duration of the exam: 2.5 hours. Exercise 1 We consider a database containing geometrical features of iris plants. The dataset can be loaded with the following commands: import pandas as pd

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 - January 19th 2021 Duration of the exam: 2.5 hours. Exercise 1 We consider a database containing geometrical features of iris plants. The dataset can be loaded with the following commands: import pandas as pd

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 - January 19th 2021 Duration of the exam: 2.5 hours. Exercise 1 We consider a database containing geometrical features of iris plants. The dataset can be loaded with the following commands: import pandas as pd import numpy as np import matplotlib.pyplot as plt data = pd.read_csv(’http://archive.ics.uci.edu/ml/machine-learning-databases/iris/ iris.data’, header = None).to_numpy() A = data[:, :4].T.astype(np.float64) labels = data[:,4] groups = (’Iris-setosa’,’Iris-versicolor’,’Iris-virginica’) Each column of the matrix A refers to a sample. Each rows corresponds to a feature. Specifically: ˆ the 1st row contains the sepal length in cm; ˆ the 2nd row contains the sepal width in cm; ˆ the 3rd row contains the petal length in cm; ˆ the 4th row contains the petal width in cm. The vector labels contains the class of iris plants each samples belongs to. There are three classes: ’Iris-setosa’, ’Iris-versicolor’ and ’Iris-virginica’. 1. How many samples are there in the dataset? How many samples belong to each class? 2. Perform PCA on the dataset by means of the SVD decomposition. Then, plot the trend of ˆ the singular values σk; ˆ the cumulate fraction of singular values ( ∑k i=1σi)/(∑q i=1σi); ˆ the fraction of the “explained variance” ( ∑k i=1σ2 i )/(∑q i=1σ2 i ). 3. Compute a matrix containing the principal components associated with the dataset. 4. Generate a scatterplot of the first two principal components of the dataset, grouped by label. 5. Comment on the results of point 4, in light of the results of point 2. Exercise 2 Give a brief explaination of the Gradient Descent method and motivate the introduction of the Stochastic Gradient Descent (SGD). Consider the following dataset import numpy as np m = 100…

Preview

First page of the document.

First page: 19 01 2021 E T