TP2 - (AAr)
TP2 - (AAr)
M1_ IA
Exercise 1 :
a. Given two vectors x and y of the same size, write a function that compute the sum of
x[i]*y[i] for all indices i.
b. Implement the logistic model which is used in Machine Learning to perform binary
classification. Mathematically, it is defined as
Note that x and w vectors don't have the same length. So, get around this by using one of
following tricks:
- Insert 1 at the beginning of x , and multiply it with w .
- Slice w by removing its first element w[0] , multiply the remaining elements
w[1], ..., w[Q] with x , and then add w[0] to the result.
Exercise 2 :
Linear regression is a machine learning technique that aims at predicting a continuous output
by using a parametric linear model :
w is a parameter vector to be learned from a set of input-output pairs {(xn ,yn)}. Mathematically,
the learning is equivalent to minimize the following loss function to evaluate the performance
of the model :
Implement the function that computes the loss given three inputs : the matrix X storing all the
inputs, the parameter vector w, the vector y with all the outputs.
Exercise 3 :
a. Schematize in a 2D plane, the 4 points for each Boolean function (AND, OR, XOR).
b. For each 2D plane, separate the 4 points by a single line.
c. Define a classifier without any hidden layer and a linear activation for each of the operators
AND, OR and XOR.
Check the results predicted by the classifier if they are correct.
d. In the case of the XOR operator, define a classifier based on a Multi Layer Percetron (MLP).
For its training use the following two cases: (a) linear activation. (b) Functions of non-linear
activations.