Moving course1 to course1 subdir.
This commit is contained in:
29
machine_learning/course1/mlclass-ex7-008/mlclass-ex7/recoverData.m
Executable file
29
machine_learning/course1/mlclass-ex7-008/mlclass-ex7/recoverData.m
Executable file
@@ -0,0 +1,29 @@
|
||||
function X_rec = recoverData(Z, U, K)
|
||||
%RECOVERDATA Recovers an approximation of the original data when using the
|
||||
%projected data
|
||||
% X_rec = RECOVERDATA(Z, U, K) recovers an approximation the
|
||||
% original data that has been reduced to K dimensions. It returns the
|
||||
% approximate reconstruction in X_rec.
|
||||
%
|
||||
|
||||
% You need to return the following variables correctly.
|
||||
X_rec = zeros(size(Z, 1), size(U, 1));
|
||||
|
||||
% ====================== YOUR CODE HERE ======================
|
||||
% Instructions: Compute the approximation of the data by projecting back
|
||||
% onto the original space using the top K eigenvectors in U.
|
||||
%
|
||||
% For the i-th example Z(i,:), the (approximate)
|
||||
% recovered data for dimension j is given as follows:
|
||||
% v = Z(i, :)';
|
||||
% recovered_j = v' * U(j, 1:K)';
|
||||
%
|
||||
% Notice that U(j, 1:K) is a row vector.
|
||||
%
|
||||
|
||||
X_rec = Z * U(:,1:K)';
|
||||
|
||||
|
||||
% =============================================================
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user