# spopt.region.RegionKMeansHeuristic

class spopt.region.RegionKMeansHeuristic(data, n_clusters, w, drop_islands=True, seed=0)

  Solve the region-K-means problem with the constraint that each cluster forms a spatially connected component.

  Parameters:
    data{`numpy.ndarray`, `python:list`}, required

      The observations to cluster shaped `(n_samples, n_features)`.

    n_clusters `python:int`

      The number of clusters to form.

    w `libpysal.weights.W`, required

      Weights object created from given data.

    drop_islands bool

      Drop observations that are islands (`True`) or keep them (`False`). Default is `True`.

    seed `python:int`

      Random state to pass into `_seeds()`. Default is `0`.

  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 of `region_k_means`.

    iters_`python:int`

      The number of iterations for the reassignment phase.

  __init__(data, n_clusters, w, drop_islands=True, seed=0)

  Methods

  `__init__`(data, n_clusters, w[, ...]) |
  `solve`() | Solve the region k-means heuristic.

  solve()

    Solve the region k-means heuristic.