Initialize only some of the centroids in a sklearn KMeans model

22 Views Asked by At

I'm training an unsupervised learning model that needs to cluster datapoints. Right now, I possess the average of each class' datapoints for validation purposes and I need each of them to be assigned to a different class.

Let's say I have 4 classes, the averages of each class A,B,C,D and the centroids 1,2,3,4. I want the assignment to look like this:

A -> 3  
B -> 2  
C -> 1  
D -> 4

In a situation where two averages land in the same centroids like this:

A -> 3
B -> 2
C -> 1
D -> 1

i'd like to be able to retrain the model while keeping the centroids 2 and 3 as they are, since they don't need correction.

Does sklearn's KMeans allow for that?

EDIT: I'd like to do this because the class' kmeans++ random initialization performs very well for my purposes and it would require significantly more effort to reimplement it from scratch

0

There are 0 best solutions below