Professional Documents
Culture Documents
DAAI22 Exercises1
DAAI22 Exercises1
HomeWork
November 2nd, 2022
October 29, 2021
1 DA-AI - HomeWork 1
Teachingassistant:
Teaching assistant: Francesco
Gabriele Tiboni
Cappio Borlino
gabriele.tiboni@polito.it
francesco.cappio@polito.it
1.1.2 k-NN
• it’s a family of classification algorithms (one for each value of K);
• hk− NN ( x ) outputs the label y appearing in the majority of the k points xt ∈ S which are
closest to x
1
1.1.3 SVM
• optimal binary classification algorithm for linearly separable problems;
– obtained thorugh the maximization of the margin;
2
– we add slack variables and a penalty parameter C
Soft margin problem:
3
Instead of computing Φ we apply the kernel trick: k( xi , x j ) = hΦ( xi ), Φ( x j )i. An example of
possible kernel function is the RBF with parameter γ:
2
k ( x i , x j ) = e − γ ( xi − x j )
4
1.3 Exercise 2 - Linear SVM
Steps:
1. use the same data as before (same attributes and splits)
2. for different values of C ([0.001, 0.01, 0.1, 1, 10, 100, 1000]) repeat the evaluations performed
before with K
3. inspect the results:
• plot the trend of the validation accuracy for the different Cs
• try to understand how C influences the result, look at what happens with low and high
values
4. this is a multi-class problem (3 classes), look at the decision_function_shape parameter
and try to understand how it is used and how it influences the result
Example of output:
5
• for each of them select an appropriate range
• for each combination compute the validation accuracy and plot the decision boundary;
• choose the best parameters and evaluate the best model on the test set;
4. try to understand how γ influences the output;
5. compare the performance of this model with the results you obtained before.
Example of output: