KMeans.score_samples¶
- KMeans.score_samples(data)[source]¶
Computes the inertia for each of the the provided datapoints. That is, it computes the mean squared distance of each datapoint to its closest centroid.
- Parameters:
data (
Union
[ndarray
[Any
,dtype
[float32
]],Tensor
]) -- The data for which to compute the inertia values.- Return type:
- Returns:
A tensor of shape
[num_datapoints]
with the inertia of each datapoint.
Attention
When calling this function in a multi-process environment, each process receives only a subset of the predictions. If you want to aggregate predictions, make sure to gather the values returned from this method.