Model / apply · All operations

Assign rows to clusters

A variant of Score with a model

Assign each row to a cluster of a trained clustering model.

Status

In arcform

Not built yet

arcform does not do this yet. Its place on the roadmap

What other tools call it

Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).

Alteryx Designer (1)
  • Append Clusterread 2026-09-27

    Append cluster assignments from a K-Centroids solution to a data stream

KNIME Analytics Platform (2)
  • Cluster Assignerread 2026-09-27

    Assign each row to the nearest prototype of an existing cluster model

  • SOTA Predictorread 2026-09-27

    Assign rows to clusters of a trained SOTA model

Talend (1)
  • tPredictClusterread 2026-09-27

    Assign each row to a cluster with a trained clustering model; removed in favour of tPredict

Background

Applying the 1-nearest neighbour classifier to the cluster centres found by k-means clustering classifies new data into the existing clusters.[1] Classifying new data by the nearest k-means cluster centre is known as the nearest centroid classifier or Rocchio algorithm.[1] In KNIME, the Cluster Assigner node assigns new data to an existing set of prototypes, such as those from k-means, each point to its nearest prototype.[2]

When to use it

In Alteryx, the Append Cluster tool appends the cluster assignments from a K-Centroids Cluster Analysis solution to a data stream that need not be the one the solution is based on.[3] The data stream given to Alteryx's Append Cluster tool must contain the fields used to create the original cluster solution, with the same names but not necessarily the same values.[3] Reach for assignment when new rows should join segments that are already named and in use, such as last quarter's customer groups, rather than when the question is which groups exist. (Meridian's view)

For Alteryx's K-Centroids Cluster Analysis tool, clustering solutions are very sensitive to the scaling of the data, particularly where one field is on a very different scale from another.[4] Alteryx's Append Cluster tool also applies any field standardisation that was done as part of constructing the original cluster solution.[3] Wherever a tool does not carry the scaling for you, scale new rows with the training rows' means and spreads, never their own, so that distances to the centres mean what they meant when the clusters were found. (Meridian's view)

In scikit-learn, cluster.AgglomerativeClustering is a transductive method, designed to model a specific dataset but not to apply that model to unseen data.[5] Before planning to assign new rows, check that the clustering method keeps something to assign them to, such as centres or prototypes; a method that only labels its own rows has to be refitted instead. (Meridian's view)

In Alteryx's Append Cluster tool, the cluster names are consecutive integers starting with one.[3] In scikit-learn, a clusterer's predict returns values from 0 to one less than the number of clusters, and -1 for a sample that is not clustered, as in cluster.dbscan.[5] The k-means algorithm does not guarantee convergence to the global optimum, and its result may depend on the initial clusters.[1] Treat a cluster number as a label within one fitted model, and keep the model's identity beside the number wherever assignments from different fits may meet. (Meridian's view)

The method

k-means clustering aims to partition n observations into k clusters in which each observation belongs to the cluster with the nearest mean, or centroid.[1] In the assignment step of k-means, each observation is assigned to the cluster whose mean has the least squared Euclidean distance, and to exactly one cluster even if it could be assigned to two or more.[1] In scikit-learn, KMeans.predict predicts the closest cluster each sample in new data belongs to, returning the index of that cluster.[6] In the vector quantisation literature, the k-means cluster centres are called the code book, and each value scikit-learn's KMeans.predict returns is the index of the closest code.[6]

In Alteryx's K-Centroids Cluster Analysis tool, K-Means measures a point's proximity to a centroid by Euclidean distance, and K-Medians by Manhattan distance.[4] In the Predictive Model Markup Language (PMML), a centre-based cluster model defines each cluster by a vector of centre coordinates and uses a distance measure to find the nearest centre for an input record.[7] A distribution-based PMML cluster model defines its clusters by their statistics and uses a similarity measure to find the best matching cluster for a record.[7] A PMML cluster model must contain information on the distance or similarity measure used for clustering.[7] Assign new rows with the same distance the clusters were found with, which a stored model that records its measure makes easy to check. (Meridian's view)

The term k-means was first used by James MacQueen in 1967, though the idea goes back to Hugo Steinhaus in 1956.[1] The standard k-means algorithm was first proposed by Stuart Lloyd of Bell Labs in 1957 as a technique for pulse-code modulation, although it was not published as a journal article until 1982.[1] Early applications of the k-means algorithm were found primarily in signal processing and data compression, particularly in vector quantisation.[1]

Compared with the alternatives

The unsupervised k-means algorithm has a loose relationship to the k-nearest neighbour classifier, a supervised technique often confused with k-means due to the name.[1] In scikit-learn, a clusterer stores its predictions on the training data in the labels_ attribute, and fit_predict on that data is usually equivalent to fitting and then calling predict.[5]

Fuzzy c-means clustering is a soft version of k-means, in which each data point has a fuzzy degree of belonging to each cluster.[1] Gaussian mixture models trained with the expectation–maximisation (EM) algorithm keep probabilistic rather than deterministic assignments to clusters.[1] Where a row sitting between two groups matters, a soft assignment shows it; a hard assignment to the nearest centre hides it. (Meridian's view)