我想在 Matlab 中使用 kmeans 聚类中的汉明距离,但我收到一条错误消息,说我的数据必须是二进制的。
有没有办法解决?我使用的数据矩阵不能是二进制的(它具有必须允许值 0、1、2、3 的物理解释),但我使用汉明距离很重要。
我想在 Matlab 中使用 kmeans 聚类中的汉明距离,但我收到一条错误消息,说我的数据必须是二进制的。
有没有办法解决?我使用的数据矩阵不能是二进制的(它具有必须允许值 0、1、2、3 的物理解释),但我使用汉明距离很重要。
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.
根据 MATLAB文档,汉明距离度量kmeans
只能用于二进制数据,因为它是对不同位百分比的度量。
在使用该函数之前,您可以尝试将数据映射为二进制表示。如果可能,您还可以考虑使用城市街区距离作为替代方案,因为它适用于非二进制输入。