I have a huge dataset in Txt file and I did clustering by using Kmean Method, but I could not mark the centroid for each clustering.

If you know the code for that, please reply to this post,

Thank You all,

  • 4
    $\begingroup$ What have you tried? (Are you using Mathematica? I ask because there's nothing in this question or your other question today that suggests Mathematica is involved.) $\endgroup$
    – JimB
    Sep 27, 2019 at 19:50
  • $\begingroup$ I tried to use Mathematica for programming. $\endgroup$
    – Alex
    Sep 28, 2019 at 20:29
  • $\begingroup$ Data = Import[ "/Mathematica -Data \ Mining/random_data.txt", "Data"]; FindClusters[Data, 5, Method -> "KMeans"]; ListPlot[m] $\endgroup$
    – Alex
    Sep 28, 2019 at 20:35
  • 1
    $\begingroup$ You increase your chances of getting an answer by providing accessible example data and a bit of code to start with. Creating random data on the fly is always prefered over uploading the file somewhere and posting the link here, but not giving any data at all is usually seen as low effort on this site. Anyways, Mean /@ m probably does what you are asking for; it recturns the means of the point clouds. $\endgroup$ Sep 28, 2019 at 23:16

1 Answer 1


Maybe you find this useful...

Data = RandomReal[{-1, 1}, {1000, 2}];
m = FindClusters[Data, 5, Method -> "KMeans"];
 VoronoiMesh[Mean /@ m, Transpose[List @@ BoundingRegion[Data]]],
 ListPlot[m, PlotRange -> List @@ BoundingRegion[Data]],
 ListPlot[Partition[Mean /@ m, 1]]

enter image description here


Your Answer

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

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