I had an idea for a spinoff of Weekly Challenge #199. The objective was to add carpooling, where a group of friends (determined by proximity) would meet to then determine the top three theaters to minimize total distance traveled.
I achieved the grouping part of the problem using the K-Centroid Cluster Analysis tool, with three clusters (representing three cars). However, one of the clusters has a size of six, which would be fine if the vehicles had indeterminate passenger capacity. However, I would like to limit the clusters to a size of five, representative of a common sedan.
Is there a way to limit cluster size when using predictive grouping tools?
Hey, @teharrell. That's an interesting question. I looked in the K-Centroids Cluster Analysis tool and I can count (in this example) the number of records it is assigning to each cluster and which they belong to, but they're anonymized. The R code doesn't seem to have anything in it that would easily allow you to specify the minimum or maximum size of a cluster. I did find a GitHub repo that answers your question using Python. Here's another example of the Python code. Perhaps you can try using the Python tool in Alteryx to solve this. A relevant snippet is shown below.