K-means编码实现
我正在寻找 k-means 的实现,它也可以找出每行数据所属的位置。
我找到了其他链接,例如 Matlab:K-means clustering 但他们没有帮助。
所以我正在寻找这样的东西。如果我的数据如下,
1, 2, 4, 5, 6, 7, 8, 9
1, 4, 7, 8, 9, 4, 5, 6
我想知道第 1 行属于簇 A,第 2 行属于簇 B,依此类推。
有谁知道Matlab是否可以向我展示这一点,如果可以的话如何?如果没有,是否有人有一些代码的链接可以做到这一点?
I am looking for an implementation of k-means that will out where each row of data belongs too.
I have found other links like Matlab:K-means clustering
But they do not help.
So I am looking for something like this. If my data is as follows
1, 2, 4, 5, 6, 7, 8, 9
1, 4, 7, 8, 9, 4, 5, 6
I would like to know that Row 1 Belongs to Cluster A and Row 2 Belongs to Cluster B and so on.
Does anyone know if Matlab can show me that, if so how? If not does anyone have a link to some code that would be able to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,Statistics Toolbox 中的 kmeans 命令可以执行此操作。以下是使用工具箱提供的 Fisher Iris 数据集的示例。
meas
是在 150 个虹膜上测量的四个解剖变量(花瓣长度、花瓣宽度、萼片长度、萼片宽度)的 100x4 数据集。输出变量(我在这里称为clusterIndex)告诉您数据集的每一行属于哪个簇,并且可以用作例如绘图中颜色点的变量。Yes, the kmeans command from Statistics Toolbox will do this. Here's an example using the Fisher Iris dataset that is supplied with the toolbox.
meas
is a 100x4 dataset of four anatomical variables (petal length, petal width, sepal length, sepal width) measured on 150 irises. The output variable, which I've here calledclusterIndex
, tells you which cluster each row of the dataset falls into, and can be used, for example, as a variable to color points in a plot.