spopt.region.RegionKMeansHeuristic¶
- class spopt.region.RegionKMeansHeuristic(data, n_clusters, w, drop_islands=True, seed=0)[source]¶
Solve the region-K-means problem with the constraint that each cluster forms a spatially connected component.
- Parameters:
- data{
numpy.ndarray,list}, required The observations to cluster shaped
(n_samples, n_features).- n_clusters
int The number of clusters to form.
- w
libpysal.weights.W, required Weights object created from given data.
- drop_islandsbool
Drop observations that are islands (
True) or keep them (False). Default isTrue.- seed
int Random state to pass into
_seeds(). Default is0.
- data{
- Attributes:
- labels_
numpy.array Region IDs for observations.
- centroids_
numpy.ndarray Floating point array of centroids in the shape of
(k, n_features)found at the last iteration ofregion_k_means.- iters_
int The number of iterations for the reassignment phase.
- labels_
Methods
__init__(data, n_clusters, w[, ...])solve()Solve the region k-means heuristic.