spopt icon indicating copy to clipboard operation
spopt copied to clipboard

Error: Islands must be larger than the quorum.

Open benjaminrhoyle opened this issue 1 year ago • 2 comments

I'm trying to use the SKATER model, and continue to run into issues with the ValueError: Islands must be larger than the quorum. If not, drop the small islands and solve for clusters in the remaining field.

I've been following the examples provided on their website with no success. I'm using spopt 0.6.1.

sf_kwds = dict(
    dissimilarity=skm.manhattan_distances,
    affinity=None,
    reduction=np.sum,
    center=np.mean
)

model = Skater(
    gdf = cluster_zips_scaled, 
    w = weights,
    attrs_name = ['counter'],
    n_clusters = 6, # k_optimal
    floor = 98,
    trace = False,
    islands = "increase",
    spanning_forest_kwds = sf_kwds)
model.solve()

cluster_zips_scaled[f"skater{k_optimal}_label"] = model.labels_

My weights dictionary has no islands, and there are 636 geometries I'm trying to cluster into 6 clusters, and I want at least 98 geometries in each cluster. Given the weights, all geometries border at least one other geometry.

Any help would be appreciated.

benjaminrhoyle avatar Sep 09 '24 21:09 benjaminrhoyle

sorry, it's really hard to diagnose without a peek at your data/weights. Any chance you can provide a reprex?

knaaptime avatar Sep 10 '24 18:09 knaaptime

The error is somewhat misleading due to our change in terminology. The error should be warning about disconnected components, not islands.

Are there disconnected subgraphs in weights that have more than 98 observations? You can check the weights.connected_components_, and can dig into it further using scipy.sparse.csgraph.connected_components() on your weights.sparse to investigate.

ljwolf avatar Nov 13 '24 16:11 ljwolf