
If classification is the task where you bring the categories, clustering is the one where you let the data tell you what the categories should be. That single difference makes it one of the most useful and most underused techniques in SEO, because so much of our work starts with a pile of unlabelled text, pages, keywords, reviews, transcripts, and the question “what is actually in here?”
This post covers what clustering is, the families of clustering algorithms and the specific ones you will meet, why text clustering is its own beast, and a proper tour of the SEO and marketing projects where it pays off. It is the conceptual grounding for the practicals that follow in the course, where we actually cluster content with KeyBERT, LDA and BERTopic.
What clustering is
Clustering is partitioning an unlabelled dataset into groups of similar objects. It is an unsupervised approach whose whole goal is to gain insight from data that has no labels, by grouping data points that share characteristics. You can cluster documents, pages, keywords, images or numeric data, with a little transformation.
Mechanically, it forms groups of homogeneous data points out of a heterogeneous dataset. The algorithm measures how similar points are, using metrics like Euclidean distance, cosine similarity or Manhattan distance for numeric data, then groups the most similar points together. The clusters it finds can be any shape, not just neat circles, which matters more than it sounds when your data is messy and real.
Hard versus soft clustering
The first way clustering splits is by how membership is assigned.

In hard clustering, every point belongs to exactly one cluster. A customer born in 1995 is either Gen Z or Millennial, never both, because the cutoff is fixed. In soft (or fuzzy) clustering, each point gets a probability of belonging to several clusters. That same 1995 customer might be 85% Gen Z and 15% Millennial based on their actual behaviour, which is exactly the nuance you want when segments overlap or when a document covers multiple topics.
The families of clustering algorithms
The second split is by method, and knowing these five families helps you pick sensibly.

Centroid-based (K-means) organises data around cluster centres. It is efficient and the most beginner-friendly, but you must tell it how many clusters you want, and it is sensitive to outliers. Density-based (DBSCAN, Mean Shift, OPTICS) connects dense regions into clusters of any shape, works out the number of clusters itself, and leaves outliers unassigned, which makes it excellent for anomaly detection. Distribution-based (Gaussian Mixture Models for numbers, LDA for text) assumes the data is a mix of probability distributions, and the probability a point belongs to a cluster falls as it moves from the distribution’s centre. Hierarchical (BIRCH) builds a tree of clusters you can cut at any level, ideal for taxonomies. And grid-based (CLIQUE) lays a grid over the data and selects cells for inclusion.
The popular algorithms you will actually meet
Within those families, a handful of algorithms come up again and again. Recognising how each behaves saves you a lot of trial and error.

K-means is the most widely used, simple and beginner-friendly, but it is hard clustering and you must define the number of clusters, usually by trial and error.
Hierarchical clustering builds a tree, either agglomerative (bottom-up, each point starts alone and merges) or divisive (top-down, everything starts as one cluster and splits).
Gaussian Mixture Models (GMM) are softer and more flexible than K-means because they learn the distribution of the data.
BIRCH handles very large datasets where K-means cannot scale, often as a first summarising pass.
Mean Shift finds its own number of clusters, great when you have no idea of the patterns in your data.
And DBSCAN (density-based spatial clustering) treats clusters as dense regions and, crucially, isolates noise points instead of forcing them into a cluster, which is why it shines at anomaly detection.
Why text clustering is different
Here is the part that matters most for us, because we live in text. Most classic clustering assumes numeric data. When your input is text, it first has to become numbers, through vectorisation, word embeddings or transformer embeddings, and embeddings are what make modern approaches work.

Text is high-dimensional, needs heavy preprocessing (tokenisation, stopword removal, lemmatisation), and relies on embeddings to capture meaning so that synonyms and context are handled properly. This is why the algorithms you reach for on text, spectral clustering, hierarchical clustering, LDA, and neural or transformer-based approaches, differ from the K-means and DBSCAN you would use on numbers. Neural networks come in specifically to generate the contextual embeddings that feed the clustering step. And yes, you can also cluster images, usually with K-means or BIRCH, by turning them into numeric vectors first.
Where clustering fits in SEO
This is where it gets practical, and clustering shows up in far more places than most people expect. Here is the tour.

Topic modelling is the flagship use: uncovering themes from large sets of unstructured text (blogs, product descriptions, reviews) with LDA or BERTopic. The models pull out the core terms that describe each topic, and the topics can be as granular as you like. Run it on your own site and you can improve internal linking, sanity-check whether your content still aligns with your positioning, and spot gaps against competitors; run it on YouTube titles or transcripts and you can read a new platform’s competitive landscape fast. It works best paired with sentiment and entity analysis on first-party data.
Keyword-to-topic mapping is topic modelling on short text: use BERT embeddings to group your keyword universe by semantic similarity into clusters like “summer clothes”, “maternity” or “festival wear”. BERTopic works well here, and I love the example from Ryan Jones, who used a topic-modelling approach to cluster keywords and lay them out as a treemap sized by search volume. Keyword clustering with KeyBERT takes a related angle, grouping keywords by shared terms and n-grams (unigram, bigram or trigram), which is perfect for building silos. There is a full KeyBERT keyword-clustering walkthrough and a guide to mapping keywords to topics you can start with today.
Customer segmentation moves to numeric data: cluster customers by purchasing frequency, average order value and behaviour with K-means or GMM, pulling data from your CRM and GA4, then profile each segment (parents, income group, family size) for targeted campaigns. Image clustering is a niche but lovely one for ecommerce: group product images by colour or style with K-means (via Google Vision API or Amazon Rekognition) to improve categorisation, recommendations and internal linking on product pages. Competitor analysis clusters competitor domains by performance metrics, domain authority, organic traffic, keywords ranked, backlinks, using K-means, DBSCAN or hierarchical clustering over a pandas dataframe, to see who is really in your topical space versus who just looks big. And anomaly detection uses DBSCAN-style algorithms (the PyOD library is purpose-built for this) to flag unusual traffic spikes, spammy backlinks or odd customer behaviour as the outliers that do not fit any cluster.
The thread running through all of these: start small. Pick one specific project, try an algorithm, see what works, then scale as you see the value, into new data types, new algorithms and new APIs.
Free resource
Deciding between approaches for text? The free BERTopic: Benefits and Limitations guide is a good place to weigh up modern topic modelling before you commit.
Where this goes next
This post covers what clustering is and where it fits. The Introduction to Clustering module inside Introduction to Machine Learning for SEO then takes you into the hands-on practicals: keyword clustering with KeyBERT, and clustering page content with both LDA and BERTopic, including how to evaluate topic quality and choose between the approaches. Read the companion posts on topic modelling with LDA and with BERTopic next.
Related glossary terms
MLforSEO Academy
Take your skills further — pick your path
Semantic ML-enabled Keyword Research
by Lazarina Stoy
Query understanding, search intent and semantic clustering for how people and AI really search.
View course →AI Search Optimisation & Agentic SEO
by Beatrice Gamba
How agentic systems retrieve, evaluate and select — and how to become the source they cite.
View course →AI Search, LLMs, Entity SEO & Knowledge Graph Strategies
by Beatrice Gamba
Build the entity authority and knowledge-graph presence that makes AI recognise and trust your brand.
View course →Introduction to Machine Learning for SEO
by Lazarina Stoy
Ship practical ML workflows — classification, clustering, entity extraction — no CS degree required.
View course →




