How can cluster assignments be used as features in a downstream supervised model, and what leakage risks arise?

Last updated 11 November 2026

  • Encode clusters as one-hot IDs, distances to centroids (KMeans.transform), or GMM soft memberships (predict_proba). This mainly helps linear models capture local nonlinear structure.

  • Leakage arises from fitting clusters on the full dataset (test rows shape centroids), including the target in clustering inputs, non-out-of-fold target encoding, using future data, or transductive methods causing train/serve skew.

  • Avoid it by putting the clusterer inside a Pipeline so it is re-fit per CV fold. Use inductive methods (k-means, GMM) for scoring and respect time splits.

  • https://medium.com/data-science/cluster-then-predict-for-classification-tasks-142fdfdc87d6
  • https://pmc.ncbi.nlm.nih.gov/articles/PMC12938195/
  • https://www.tutorialspoint.com/machine_learning/machine_learning_k_means_clustering.htm
All Clustering interview questions