1

我想在 Matlab 中使用 kmeans 聚类中的汉明距离,但我收到一条错误消息,说我的数据必须是二进制的。

有没有办法解决?我使用的数据矩阵不能是二进制的(它具有必须允许值 0、1、2、3 的物理解释),但我使用汉明距离很重要。

4

2 回答 2

1

The data to cluster must be of type logical. You can convert your 0/1 double, single, uintX data by a single command:

x = logical( y );

If you want to convert uint8 type data to binary, check the function uint8tobit(). Take a look at de2bi() and bi2de() functions.

于 2012-07-19T21:40:15.000 回答
1

根据 MA​​TLAB文档,汉明距离度量kmeans只能用于二进制数据,因为它是对不同位百分比的度量。

在使用该函数之前,您可以尝试将数据映射为二进制表示。如果可能,您还可以考虑使用城市街区距离作为替代方案,因为它适用于非二进制输入。

于 2012-02-21T13:48:02.703 回答