Created
April 20, 2020 16:12
-
-
Save theptrk/01e7d0eecb438ce7df36e39c93398363 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Z = projectData(X, U, K) | |
% Initalize | |
Z = zeros(size(X, 1), K); | |
% index to create Ureduce | |
Ureduce = U(:, 1:K) | |
for i=1:size(Z,1) | |
% say X is all examples at dimension n (m, n) | |
% x is a single example (1, n) | |
x = X(i, :); | |
% we multiple the example by Ureduce to reduce dimensionality | |
% z is (1, n) * (n, K) = (1, K) | |
z = (X(i, :) * Ureduce) | |
% set z in the Z matrix | |
Z(i, :) = z; | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment