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:
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.

Returns:
of that assignment.