Clustering
Group similar rows without a target: set-up, algorithms, and how to judge the clusters.
Clustering groups rows that look alike. There is no target column: the algorithm finds the groups by itself, and you decide whether they are useful. Typical uses are customer segments, product groupings and exploring a new dataset.
When to use it
Use clustering when you have no labels and want to discover structure. If you do have a label to predict, use Classification. If you want to find the few rows that do not fit any group, use Anomaly detection.
Set it up
Create the pipeline
Open Pipelines, select New and then New pipeline. Set Task to Clustering, pick the Dataset and select Create pipeline. There is no Target column for this task. The dataset list shows only data sources added as CSV files.
Scale the columns
Most clustering algorithms use distances between rows, so a column measured in thousands outweighs one measured in fractions. Add a Standard Scaler (or another scaler) on the numeric columns. The Customer segmentation use case does exactly this on four columns before training K-Means and Agglomerative Clustering on the jewellery sample. See Preprocessing steps.
Choose algorithms
Open the Models part of the pipeline editor and tick the algorithms. There is no Cross-validation card for clustering, because there is nothing to hold out and score. Select Train N models.
Algorithms
The catalog has K-Means, Agglomerative, Birch, Spectral, Affinity Propagation, Mean Shift, DBSCAN, OPTICS and, when the server has the library installed, K-Modes. See the Algorithms catalog.
Choosing the number of clusters
Algorithms such as K-Means, Agglomerative, Spectral and Birch need the number of clusters in advance. Their default is 4. To change it, switch the algorithm to Manual and edit its cluster-count parameter (see Hyperparameters and tuning). Other algorithms, such as DBSCAN, OPTICS, Mean Shift and Affinity Propagation, decide the number themselves from density or similarity settings.
To choose a number, train a few values and compare the Elbow curve and the Silhouette score plot described below. Look for the point where adding clusters stops improving the picture, then check that the groups make sense to someone who knows the data.
Plots
Clustering runs are judged mainly through plots. Open a model with View details.
| Tab | Plots |
|---|---|
| Diagnostics | Cluster sizes, Silhouette per cluster |
| Curves | Elbow curve, Silhouette score |
| Raw | 2-D embedding |
- Cluster sizes shows how many rows are in each cluster. One huge cluster and several tiny ones is a warning sign.
- Silhouette per cluster shows, for every row, how much closer it is to its own cluster than to the next nearest one. Values near 1 are good; values near 0 or below 0 mean the row sits between clusters.
- 2-D embedding projects the rows to two dimensions and colors them by cluster.
In the current version the leaderboard for clustering runs has no metric columns, because the training step does not produce a cross-validation table for unsupervised models. The model metrics that the engine defines (Silhouette, Calinski-Harabasz, Davies-Bouldin) are described in the Metrics reference, and the plots above show the silhouette values.
Using the result
The result is a model that assigns each row a cluster label such as "Cluster 0". Use the cluster as a new column to profile segments: compare the average of each column per cluster and give each cluster a name that a colleague would understand.
Next steps
Learn the theory
Lessons on learning.mlflow.es that explain the ideas behind this page.
Updated 2026-11-22