I am using scikit-learn MiniBatchKMeans to do text clustering.

In the fit() function there is a parameter sample_weight described as follows:

The weights for each observation in X. If None, all observations are assigned equal weight (default: None).

How should I interpret it exactly?

For instance, if I assigned greater weight to certain observations, will the centroid be nearer to that observations?


1 Answer 1


Yes, the parameter is available in the vanilla K-Means too.

The algorithm supports sample weights, which can be given by a parameter sample_weight. This allows assigning more weight to some samples when computing cluster centers and values of inertia. For example, assigning a weight of 2 to a sample is equivalent to adding a duplicate of that sample to the dataset X.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.