Bug introduced in 11.3 or earlier and persisting through 12.0
Bug isn't present in version 8.0.4
I am trying to do clustering and then obtained a plot as below:-
pts = {{1, 1}, {2, 1.5}, {10, 1}, {11, 1.5}};
clts = FindClusters[pts, 2]
ListPlot[clts, PlotRange -> {{0, 12}, {0, 3}}]
As we can see, the 2 points at the left are closer to each other, but they are now put in separated clusters. Why does that happen?
If I reverse the x-y coordinate of the points, the situation is still the same (that means FindClusters
is not taking priority for x-coordinates). I then tried FindClusters[pts, 2, CriterionFunction -> "CalinskiHarabasz"]
, the 2 closer points are still in different clusters. Finally, when I tried FindClusters[pts1, 2, DistanceFunction -> EuclideanDistance]
, the problem is finally solved and the 2 closer points are in the same cluster.
So I am curious: if the default distance is not the "Euclidean distance", what would that be? Why would it put the closer points into different clusters?
Trace[FindClusters[pts, 2], HoldPattern[DistanceFunction -> _]]
shows a lot ofDistanceFunction -> EuclideanDistance
, soFindClusters
appears to be usingEuclideanDistance
as default. $\endgroup$FindClusters
internally usesMachineLearning`PackageScope`AutomaticDistanceFunction[Automatic][{"Numerical", "Numerical"}]
as its distance function, which evaluates toEuclideanDistance
. Huh. $\endgroup$EuclideanDistance
on Mathematica versions 11.1.1 and 11.2.0 on Windows, and 11.3.0 on Linux. $\endgroup$