I have read that retraining a model depends highly on what you are trying to achieve. I am conscious that maybe I need to retrain my model daily and after a certain time I have to train the model again from scratch. That's no problem. The thing is, if I were to retrain a K-Modes model, I would need the previous centroids saved. I think this is also not a problem. Seeing the implementation of K-Modes here, the parameter init can be Huang or Cao. In the K-Means implementation of sklearn (see here), we can pass a ndarray of shape (n_clusters, n_features). I can't find this feature in the K-Modes implementation. So my specific questions are:

  1. Is saving the previous centroids sufficient to retrain the model?
  2. Is there a way to pass previous centroids in the K-Modes implementation I have mentioned? If not, should I implement my own K-Modes?

1 Answer 1


There's dedicated pypi package for incremental/online learning. It's called Creme and here's there repo. It contains KMeans implementation. Though under the hood, there's no incremental stuff going on, as you need all data in a pass (read more about Lloyd's algoritm here).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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