Ng機器學習 Week8 Unsupervised Learning

Clustering

Q1&Q2
Q3&Q4
Q5

Principal Component Analysis

Q1
Q2&Q3 Q2選2。。。手滑
Q4&Q5

Quiz

findClosestCentroids.m

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

computeCentroids.m

for i = 1:K
    centroids(i,:) = (X' * (idx == i)) / sum(idx == i);   %X' * (idx == i)  To add x in same center 
end 

kMeansInitCentroids.m

% Randomly reorder the indices of examples
randidx = randperm(size(X, 1));
% Take the first K examples as centroids
centroids = X(randidx(1:K), :);

pca.m

sigma = X' * X / m;     % compute the covariance matrix
[U,S,V] = svd(sigma);   % SVD

projectData.m

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

recoverData.m

X_rec = Z * U(:,1:K)'; 
發佈了37 篇原創文章 · 獲贊 12 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章