Model Evaluation
Silhouette Score
In shortA clustering quality metric from -1 to 1 that compares how close each point is to its own cluster versus the nearest other cluster.
The silhouette score measures how well data points fit the clusters they have been assigned to. For each point, it compares the average distance to the other members of its own cluster with the average distance to the members of the nearest neighbouring cluster. Scores range from -1 to 1: higher means tight, well-separated clusters. It is one of the most common ways to evaluate clustering when there are no labels to check against.
How it works
For each data point, two values are calculated: a, the mean distance to the other points in the same cluster, and b, the mean distance to the points in the nearest other cluster. The point’s silhouette is (b – a) / max(a, b). A value near 1 means the point is far closer to its own cluster; near 0 means it sits on the border between two clusters; a negative value suggests it may be in the wrong cluster. The overall score is the average across all points.
In scikit-learn, silhouette_score(X, labels) returns this average. A common rule of thumb, used in MLforSEO’s practicals, treats scores above 0.5 as well separated; the guidance usually quoted from Kaufman and Rousseeuw (Rousseeuw introduced the measure in 1987) describes values above 0.7 as strong structure.
How it’s used in SEO and marketing
- Choosing the number of clusters: run k-means for several values of k and compare scores, alongside the elbow method.
- Customer segmentation: checking that segments are genuinely distinct before building campaigns for them.
- Content and keyword clustering: comparing embedding models or algorithms on the same data.
- Image clustering: validating colour or feature-based groupings of product images.
Example
MLforSEO’s internal linking script clusters page embeddings with k-means and picks the number of clusters automatically by silhouette score. If k=8 scores 0.41 and k=12 scores 0.29, the script chooses eight. The resulting clusters are then named with c-TF-IDF and checked by a person before they shape hubs and links.
Limitations and things to watch
- A good score does not guarantee useful clusters. Always read samples from each cluster and ask whether the team can act on them.
- It favours compact, round clusters and can mislead with density-based methods such as HDBSCAN, where noise points need special handling.
- Scores on high-dimensional embeddings tend to be low and are best used for comparison, not as absolute grades.
- It is slow on very large data sets; scikit-learn lets you compute it on a sample.
- For topic models, use coherence score instead.
Learn it on MLforSEO
- Customer Segmentation with Machine Learning Using Three Clustering Approaches
- Image Clustering by Color with Three Machine Learning Approaches for Visual Content Organization
- What Machine Learning Clustering Is, and Where It Fits in SEO
- 10 Ways to Automate Internal Linking with AI
- Introduction to Machine Learning for SEO (course)
Where Silhouette Score shows up on MLforSEO
Learn it in a course
Sources and further reading
- https://www.mlforseo.com/machine-learning-tutorials/topic-modeling-clustering/what-ml-clustering-is-and-where-it-fits-in-seo/ MLforSEO
- https://www.mlforseo.com/machine-learning-implementation-guides/internal-link-analysis/automate-internal-linking-ai/ MLforSEO
- https://www.mlforseo.com/courses/introduction-to-machine-learning-for-seo/ MLforSEO
- scikit-learn: silhouette_score
- Rousseeuw (1987), Silhouettes: a graphical aid to the interpretation and validation of cluster analysis
Other terms from Model Evaluation
- Accuracy (ML metric)Accuracy is the share of all predictions a model gets right. It is the simplest evaluation metric, but it misl…
- Coherence ScoreA metric for how interpretable a topic model's topics are, based on how often each topic's top words appear to…
- Cosine SimilarityA measure of how closely two vectors point in the same direction, used to score how similar two texts, keyword…
- Emotion ScoresPer-emotion scores (joy, sadness, fear, disgust, anger) an emotion analysis API assigns to a text, each from 0…
- Entity Salience ScoreA 0 to 1 score from Google's Natural Language API showing how central each extracted entity is to the analysed…
- F1 ScoreA single evaluation metric that balances precision and recall (their harmonic mean); useful when classes are i…
- LLM-as-a-JudgeUsing a large language model to score or compare outputs against a rubric, as a scalable stand-in for human re…
- OverfittingOverfitting is when a model learns its training data too closely, including noise, so it scores well in traini…
- Precision and RecallPrecision is the share of a model's positive results that are correct; recall is the share of all true positiv…
