I have a dictionary containing people and the distance between each pair in the following format:

    "ID_person1": {"ID_person2": 100, "ID_person3": 50},
    "ID_person2": {"ID_person1": 100, "ID_person3": 40},
    "ID_person3": {"ID_person1": 50, "ID_person2": 40},

Since I have all distances between pairs, I'm using K-means to divide them into k clusters (groups), given k, where all elements in a group are as close as possible to the other elements in the same group.

Since K-means is iterative, is there any ohter way to detect crowds with better performance.

  • $\begingroup$ can you share a sample (reproducible) of the structure of your data? $\endgroup$ – Julio Jesus Jan 4 at 23:40
  • $\begingroup$ without more context, I would go with a density-based algorithm such as DBSCAN, since I assume you do not have a prior knowledge of the number of clusters $\endgroup$ – Julio Jesus Jan 4 at 23:42
  • $\begingroup$ I also assume you should create an X matrix with features for each personid for example mean distance of its k closest neighbours, closest id, remotest id, etc and whit that matrix you can now apply a cluster algorithm $\endgroup$ – Julio Jesus Jan 4 at 23:46
  • $\begingroup$ Let me edit the structure of my data. The number of clusters should be relation between the number of people and the number of elements in a group. I think it's not part of the algorithm discussed here because it's quite easy. $\endgroup$ – Maf Jan 5 at 0:14

Your Answer

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

Browse other questions tagged or ask your own question.