Machine Learning in MATLAB: Roland Memisevic
Machine Learning in MATLAB: Roland Memisevic
Roland Memisevic
I We are often dealing with lots of data, and normally that data
is given in the form of real-vectors. If not, we can often
massage it accordingly... (performing feature extraction).
I It is convenient to use matrices to store data, for example by
stacking the vectors column-wise:
X = (x1 x2 . . . xN )
wTx ( =
X
wk xk )
k
I Perceptrons, back-prop networks, support vector machines,
logistic regression, PCA, (nearest neighbors), ...
Vectorizing
I Applying the linear function to data-points stacked
column-wise in a matrix X is simply Y = wT X .
In MATLAB:
Y = w*X;
I In MATLAB writing stuff in matrix form can be faster than
using loops. Referred to as vectorization.
I Another example. Suppose you want to mean center a set of
vectors stored in X . Instead of
m = mean(X,2);
for i = 1 : size(X,2)
X(:,ii) = X(:,ii) - m;
end
we could write:
X = X - repmat(mean(X,2),1,size(X,2));
Linear regression
f (x) = sgn(wT x)