1
$\begingroup$

[Cross-posted on the Wolfram Community.]

I just found out that there's a difference in the number clusters retrieved when using FindClusters and ClusteringComponents for the same data set, even when completely the same settings are used:

Do[koppels = RandomReal[{0, 100}, 500];
 cl = FindClusters[koppels, DistanceFunction -> EuclideanDistance, 
   Method -> "Optimize"];
 indices2 = 
  ClusteringComponents[koppels, Automatic, 1, DistanceFunction -> EuclideanDistance, 
   Method -> "Optimize"];
 Print[{First@Dimensions[cl], Max[indices2]}];, {i, 1, 6}]

{2,2}

{2,2}

{1,2}

{2,2}

{1,2}

{1,2}

This shouldn't be the case, because the same clusters should be found either way. Does someone have an idea of what's going on here?

$\endgroup$
2
  • 3
    $\begingroup$ If you're going to ask this question simultaneously here and at Wolfram Community, you should mention that at both sites. Also if you get an answer, you should edit your question with a link to that answer. $\endgroup$ – JimB Nov 10 '16 at 19:11
  • $\begingroup$ It is important that questions cross-posted between MSE and Wolfram Community be clearly marked as such, with links provided from each to the other. That way we avoid replication of effort in responses. $\endgroup$ – Alexey Popkov Mar 19 '17 at 8:11
2
$\begingroup$

A reply from Giorgia Fortuna (WRI) in the duplicate thread on the Wolfram Community:

FindClusters and ClusteringComponents have gone under massive reconstruction. However, when calling Method->"Optimize" you use the old ones.

  1. The old FindClusters/ClusteringConponents were not using the same algorithms on the back, that is the reason why you got different results.

  2. The new ones give the same result (see below).

If you look at the documentation of these functions you will notice that the method "Optimize" has been removed. The reason being that ideally we don't want the user to use the old code ever. However for back compatibility we need to accept this method.

Do[koppels = RandomReal[{0, 100}, 500];
 cl = FindClusters[koppels, DistanceFunction -> EuclideanDistance];
 indices2 = 
  ClusteringComponents[koppels, Automatic, 1, 
   DistanceFunction -> EuclideanDistance];
 Print[{First@Dimensions[cl], Max[indices2]}];, {i, 1, 6}]

{5,5}

{5,5}

{6,6}

{6,6}

{5,5}

{5,5}

The above output is apparently from version 11. Here is output from version 10.4.1:

{2,2}

{1,2}

{3,2}

{1,2}

{2,2}

{2,2}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.