Matlab:K-均值聚类 [英] Matlab:K-means clustering

查看:70
本文介绍了Matlab:K-均值聚类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个矩阵A(369x10),我想将其集群为19个集群. 我用这种方法

I have a matrice of A(369x10) which I want to cluster in 19 clusters. I use this method

[idx ctrs]=kmeans(A,19)

产生 idx(369x1)和ctrs(19x10)

which yields idx(369x1) and ctrs(19x10)

我到这里为止.我在A中的所有行都聚集在19个簇中.

I get the point up to here.All my rows in A is clustered in 19 clusters.

现在我有一个数组B(49x10).我想知道在给定的19个簇中,这个B的行在哪里对应.

Now I have an array B(49x10).I want to know where the rows of this B corresponds in the among given 19 clusters.

在MATLAB中怎么可能?

How is it possible in MATLAB?

提前谢谢

推荐答案

我想不出比您描述的更好的方法.内置函数可以节省一行,但我找不到.这是我要使用的代码:

I can't think of a better way to do it than what you described. A built-in function would save one line, but I couldn't find one. Here's the code I would use:

[ids ctrs]=kmeans(A,19);
D = dist([testpoint;ctrs]); %testpoint is 1x10 and D will be 20x20
[distance testpointID] = min(D(1,2:end));

这篇关于Matlab:K-均值聚类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆