Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
mapclassify.Natural_Break() does not return the specified k classes #16
I use mapclassfiy.Natural_Break() to produce bins for my MapBox heatmap.
My code like this:
In my thought it should return 5 classes, but it only returned 3 classes
Attachment is the
Thank you for opening the issue.
I think the problem lies in the kmeans function from scipy used in mapclassify.Natural_Breaks to cluster the input data. This issue is related to issues 1 and 2 opened in stackoverflow. The point is that k-means can fail in the sense that clusters can disappear if no data points are assigned to a cluster center in the iterative process. Therefore, a smarter initial selection of cluster center is important and one such initial smarter selection is implemented in sklearn (init=’k-means++’). I think it makes sense to switch from scipy to sklearn to make sure that the returned number of classification is identical to the number specified in the input @sjsrey @ljwolf ?