1
$\begingroup$

I am trying to ensure that both the FindCluster and ClusterClassify function provide the same cluster name.

To explain this better, I have a minimum working example in which dummy data is organized into 4 clusters.

SeedRandom[1234];
dummydata = 
  RandomSample[
   Table[x^2 + RandomReal[{-0.01, 0.01}], {x, -1, 1, 0.002}]];
ListPlot[dummydata, PlotLabel -> "dummy data", 
 PlotStyle -> {Black, PointSize -> 0.02}]

fig 1: dummy data

enter image description here

cdummy = FindClusters[dummydata, 4];
ListLinePlot[{cdummy[[1]], cdummy[[2]], cdummy[[3]], cdummy[[4]]}, 
 PlotStyle -> {PointSize -> 0.02}, PlotLegends -> Automatic, 
 PlotLabel -> "dummy data in 4 clusters"]

Notice the plot legend labeling for the 4 clusters.

fig 2: dummy data organized into 4 clusters

enter image description here

Classifying the dummy data into 4 clusters so that given any data point, I know what cluster it belongs to.

cdummyClassify = ClusterClassify[dummydata, 4]
{cdummyClassify[0.92], cdummyClassify[0.99], cdummyClassify[0.52], 
 cdummyClassify[0.55], cdummyClassify[0.02]}

Now, I create a cluster classification object which would allow me to identify the data cluster any given point in the future belongs to.

cdummyClassify = ClusterClassify[dummydata, 4]
{cdummyClassify[0.92], cdummyClassify[0.99], cdummyClassify[0.52], 
 cdummyClassify[0.55], cdummyClassify[0.02]}

Although the classification of data points is correct, the cluster label is not the same as that of fig 2. How do I ensure that the same clustering label is used for both FindClusters and ClusterClassify?

(*{2, 2, 4, 4, 1}*)
$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.