How to determine if two partitions (clusterings) of data points are identical?

后端 未结 3 1771
误落风尘
误落风尘 2020-12-11 19:27

I have n data points in some arbitrary space and I cluster them.
The result of my clustering algorithm is a partition represented by an int vector l

3条回答
  •  抹茶落季
    2020-12-11 19:45

    In matlab:

    function tf = isIdenticalClust( l_1, l_2 )
    %
    % checks if partitions l_1 and l_2 are identical or not
    %
    tf = all( accumarray( {l_1} , l_2 , [],@(x) all( x == x(1) ) ) == 1 ) &&...
         all( accumarray( {l_2} , l_1 , [],@(x) all( x == x(1) ) ) == 1 );
    

    What this does:
    groups all elements of l_1 according to the partition of l_2 and checks if all elements of l_1 at each cluster are all identical. Repeating the same for partitioning l_2 according to l_1.
    If both grouping yields the homogenous clusters - they are identical.

提交回复
热议问题