【发布时间】:2017-07-20 14:57:56
【问题描述】:
我的课堂上有一个 Matlab 代码,教授使用此代码将每个数据点分配给最近的集群,其中 c 是质心矩阵,x 是数据矩阵。
% norm squared of the centroids;
c2 = sum(c.^2, 1);
% For each data point x, computer min_j -2 * x' * c_j + c_j^2;
% Note that here is implemented as max, so the difference is negated.
tmpdiff = bsxfun(@minus, 2*x'*c, c2);
[val, labels] = max(tmpdiff, [], 2);
我不确定这如何等同于通过集群分配完成的这一步的算法定义
% For every centroid j and for every data point x_i
labels(i) = `argmin||x_i - c_j||^2`
谁能给我解释一下这是如何工作的,主要是如何计算
min_j -2 * x' * c_j + c_j^2
等价于
argmin||x_i - c_j||^2
【问题讨论】: