Reputation: 11
I am using scikit's General Mixture Model to fit some data, but I would like to define the initial centroids of each cluster manually.
The scikit learn documentation states:
There is a choice of four initialization methods (as well as inputting user defined initial means) to generate the initial centers for the model components
I assume the "user defined" initial means refer to manually putting in a set of points which is what I wish to achieve. The four main methods described in the documentation rely on using algorithms to generate the initial points.
The following code is my attempt to pass an array of tuples as my initial starting points for the GMM model:
EM = GaussianMixture(n_components=3,max_iter=3,init_params=np.array([[3,3],[2,2],[-3,-3]]))
However this is not a valid implementation method. Is it possible to set the initial points manually, and if so how may I do this? If not, will I need to create the GMM model manually or is there another library I can use that can do GMM with manually set initial points?
Upvotes: 0
Views: 231
Reputation: 559
You can use the means_init
parameter:
array-like of shape (n_components, n_features), default=None
The user-provided initial means, If it is None, means are initialized using the init_params method.
Upvotes: 0