Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong clustering #34

Closed
mosikh opened this issue Sep 9, 2022 · 1 comment
Closed

Wrong clustering #34

mosikh opened this issue Sep 9, 2022 · 1 comment

Comments

@mosikh
Copy link

mosikh commented Sep 9, 2022

Hello,
I have a bunch of house points. I have extended a line which extends Glass fiber to each house.
Now, I'd like to cluster the points to assign a distributor to each cluster. The maximum of house points per cluster should be 20.
I calculated an adjacency matrix based on the Glass fiber line for the data set which has 61 points, here as an example. I do the clustering by this library and the pre-computed adjacency matrix. However, I sometimes see a wrong clustering, which is observable in the picture.

It is my code:
"am" is the adjacency matrix of distances
db = KMeansConstrained(n_clusters = 4,size_max=20, random_state=0)
result = db.fit_predict(am)

In the picture, the black line is the glass fiber line which is the base of calculation and the colorful points are the my clustered points by the algorithm. The green and yellow clusters are not in the best state, as you see.
I have sometimes the same issue with other datasets, as well.

kmeans constrained

I appreciate any help to improve the result.

Versions:

  • Python: 3.9
  • Operating system: Windows
  • k-means-constrained: 0.7.2
  • numpy: 1.23.2
  • scipy: 1.9.1
  • ortools: 9.4.1874
  • joblib: 1.1.0
  • cython (if installed): is not installed

Best regards,
Mostafa

@mosikh mosikh changed the title [BUG] Wrong clustering Sep 9, 2022
@joshlk
Copy link
Owner

joshlk commented Sep 13, 2022

You need to provide a minimum, reproducing example otherwise it’s not possible to debug this issue. Closing ticket until more information is provided.

@joshlk joshlk closed this as completed Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants