Compute the mean Silhouette Score for clustered points using Euclidean distance. For point i, let a(i) be its average distance to the other points in its own cluster, and let b(i) be the smallest average distance from the point to any other cluster.
The point score is
s(i)=max(a(i),b(i))b(i)−a(i)Return the mean of s(i) over all points as a Python float. Every cluster contains at least two points.
Input: X = [[0, 0], [0, 1], [1, 0], [5, 5], [5, 6], [6, 5]], labels = [0, 0, 0, 1, 1, 1]
Output: 0.8398
Explanation: Each point is much closer on average to its own cluster than to the other cluster.
X[:, None, :] - X[None, :, :] forms every pairwise displacement.
A boolean matrix from labels[:, None] == labels[None, :] identifies same-cluster pairs.
Set each point's own-cluster column to infinity before taking the nearest other-cluster mean.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Compute the mean Silhouette Score for clustered points using Euclidean distance. For point i, let a(i) be its average distance to the other points in its own cluster, and let b(i) be the smallest average distance from the point to any other cluster.
The point score is
s(i)=max(a(i),b(i))b(i)−a(i)Return the mean of s(i) over all points as a Python float. Every cluster contains at least two points.
Input: X = [[0, 0], [0, 1], [1, 0], [5, 5], [5, 6], [6, 5]], labels = [0, 0, 0, 1, 1, 1]
Output: 0.8398
Explanation: Each point is much closer on average to its own cluster than to the other cluster.
X[:, None, :] - X[None, :, :] forms every pairwise displacement.
A boolean matrix from labels[:, None] == labels[None, :] identifies same-cluster pairs.
Set each point's own-cluster column to infinity before taking the nearest other-cluster mean.
Sign in to take notes on this problem
Accepts: array
Accepts: array