吴恩达机器学习作业7

发布时间:2024-11-16 16:01

pca

sigma = X\' * X / m;
[U,S,V] = svd(sigma);

\"吴恩达机器学习作业7_第1张图片\"

projectData

U_reduce = U(:,1:K);
Z = X * U_reduce;

\"在这里插入图片描述\"

recoverData

U_reduce = U(:,1:K);
X_rec = Z * U_reduce\';

\"在这里插入图片描述\"

findClosestCentroids

m = size(X,1);
for i = 1:m
  ind_k = zeros(K,1);
  for j = 1:K
    ind_k(j) = sum((X(i,:) - centroids(j,:)) .^ 2);
  endfor
  [value,index] = min(ind_k);
  idx(i) = index;
endfor

\"吴恩达机器学习作业7_第2张图片\"

computeCentroids

for i = 1:K
  centroids(i,:) = ((idx == i)\' * X) / sum(idx == i);
endfor

\"吴恩达机器学习作业7_第3张图片\"

ItVuer - 免责声明 - 关于我们 - 联系我们

本网站信息来源于互联网,如有侵权请联系:561261067@qq.com

桂ICP备16001015号