Exemple #1
0
def azp(X, w, n_clusters=5, **kwargs):
    """AZP clustering algorithm.

    Parameters
    ----------
    X : array-like
         n x k attribute data
    w : libpysal.weights.W instance
        spatial weights matrix
    n_clusters : int, optional, default: 5
        The number of clusters to form.

    Returns
    -------
    fitted cluster instance: region.p_regions.azp.AZP

    """
    model = AZP()
    model.fit_from_w(attr=X.values, w=w, n_regions=n_clusters)
    return model
Exemple #2
0
def test_w_basic():
    cluster_object = AZP(random_state=0)
    cluster_object.fit_from_w(w, attr, n_regions=2)
    result = region_list_from_array(cluster_object.labels_)
    compare_region_lists(result, optimal_clustering)