function centroids = computeCentroids(X, idx, K)
%COMPUTECENTROIDS returns 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, :)
% sh
吴恩达的机器学习编程作业17:computeCentroids KMeans算法第二步 计算质心
最新推荐文章于 2023-05-29 12:58:20 发布
本文深入探讨吴恩达机器学习课程中的KMeans算法,重点解析编程作业中计算质心的步骤。通过理解质心的计算方法,帮助读者更好地掌握聚类核心概念。

最低0.47元/天 解锁文章
725

被折叠的 条评论
为什么被折叠?



