Machine Learning Week8 computeCentroids.m
来源:互联网 发布:forest类似的软件 编辑:程序博客网 时间:2024/05/28 06:08
loop over centroids
对于每一个centroid计算属于这一类的均值。
function centroids = computeCentroids(X, idx, K)%COMPUTECENTROIDS returs the new centroids by computing the means of the %data points assigned to each centroid.% centroids = COMPUTECENTROIDS(X, idx, K) returns the new centroids by % computing the means of the data points assigned to each centroid. It is% given a dataset X where each row is a single data point, a vector% idx of centroid assignments (i.e. each entry in range [1..K]) for each% example, and K, the number of centroids. You should return a matrix% centroids, where each row of centroids is the mean of the data points% assigned to it.%% Useful variables[m n] = size(X);% You need to return the following variables correctly.centroids = zeros(K, n);% ====================== YOUR CODE HERE ======================% Instructions: Go over every centroid and compute mean of all points that% belong to it. Concretely, the row vector centroids(i, :)% should contain the mean of the data points assigned to% centroid i.%% Note: You can use a for-loop over the centroids to compute this.%for i = 1:K ind = (idx==i); centroids(i,:) = sum(X(ind,:),1)/sum(ind);end% =============================================================end
0 0
- Machine Learning Week8 computeCentroids.m
- Machine Learning Week8 findClosestCentroids.m
- Machine Learning(Andrew)Week8(上)
- Machine Learning(Andrew)Week8(下)
- [week8] machine learning:clustering(聚类)
- Machine Learning displayData.m
- Machine Learning Week4 lrCostFunction.m
- Machine Learning Week4 predictOneVsAll.m
- Machine Learning Week4 oneVsAll.m
- Machine Learning Week4 ex3_nn.m
- Machine Learning Week4 ex4.m
- NG week8 unsupervised learning
- S. M. Ali Eslami / Patterns for Research in Machine Learning
- 《(1997)Machine Learning [CMU+T.M. Mitchell] 》读书笔记 - 第二章
- 《(1997)Machine Learning [CMU+T.M. Mitchell] 》读书笔记 - 第三章
- (1997)Machine Learning [CMU+T.M. Mitchell] 读书笔记 - [第一章]
- machine learning
- Machine Learning
- 对miniUI的后台读取数据理解
- android.os.TransactionTooLargeException
- Oracle删除表锁
- assgin ,copy,retain
- 【剑指offer】字符串的排列与组合
- Machine Learning Week8 computeCentroids.m
- JIRA6.3.6安装、汉化及破解
- 懵逼王学Redis----前言
- Intel IPP图像处理库下载及安装测试
- hdu 5802 Windows 10 (贪心 + 思维)
- 由于新单位不能用云笔记开始这里分享知识吧
- 终极解决java获取路径问题
- Mac下Android Studio中获取SHA1和MD5
- github搜索技巧