You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

projectData.m 949 B

8 years ago
123456789101112131415161718192021222324252627
  1. function Z = projectData(X, U, K)
  2. %PROJECTDATA Computes the reduced data representation when projecting only
  3. %on to the top k eigenvectors
  4. % Z = projectData(X, U, K) computes the projection of
  5. % the normalized inputs X into the reduced dimensional space spanned by
  6. % the first K columns of U. It returns the projected examples in Z.
  7. %
  8. % You need to return the following variables correctly.
  9. Z = zeros(size(X, 1), K);
  10. % ====================== YOUR CODE HERE ======================
  11. % Instructions: Compute the projection of the data using only the top K
  12. % eigenvectors in U (first K columns).
  13. % For the i-th example X(i,:), the projection on to the k-th
  14. % eigenvector is given as follows:
  15. % x = X(i, :)';
  16. % projection_k = x' * U(:, k);
  17. %
  18. U_reduce = U(:, 1:K);
  19. x = X';
  20. Z = x' * U_reduce;
  21. % =============================================================
  22. end

机器学习

Contributors (1)