esda.silhouettes.nearest_label¶
- esda.silhouettes.nearest_label(data, labels, metric=<function euclidean_distances>, return_distance=False, keep_self=False)[source]¶
Find the nearest label in attribute space.
Given the data and a set of labels in labels, this finds the label whose mean center is closest to the observation in data.
- Parameters:
- data(N,P)
array
to
clusteron
orDataFrame
indexed
on
the
same
values
as
that in alist.focal/alist.neighbor
- labels(N,)
array
containing
classifications
,indexed
on
the
same
values
as that in alist.focal/alist.neighbor
- metric
callable()
, array, a function that takes an argument (data) and returns the all-pairs distances/dissimilarity between observations.
- return_distance: bool
Whether to return the distance from the observation to its nearest cluster in feature space. If True, the tuple of (nearest_label, dissim) is returned. If False, only the nearest_label array is returned.
- keep_self: bool
whether to allow observations to use their current cluster as their nearest label. If True, an observation’s existing cluster assignment can also be the cluster it is closest to. If False, an observation’s existing cluster assignment cannot be the cluster it is closest to. This would mean the function computes the nearest alternative cluster.
- data(N,P)
- Returns: