Core Concepts (AI/ML)
Hyperparameter Tuning
In shortAdjusting the settings you choose before training a model, such as the number of topics or clusters, to get better, more useful results.
Hyperparameter tuning is the process of finding the best settings for a machine learning algorithm. Hyperparameters are the choices you make before or around training, such as how many topics a topic model should find, while parameters are what the model learns from the data itself. Tuning means trying different settings, measuring the results and keeping the combination that works best for your data and goal.
How it works
A typical tuning loop has four parts:
- Choose what to tune. Each algorithm has a few settings that matter most.
- Choose how to measure success. For supervised models that is usually accuracy or F1 on held-out data; for topic models, a coherence score plus your own reading of the topics; for clustering, metrics such as the silhouette score.
- Search. Try values manually, in a grid of combinations (grid search), at random (random search), or with tools that learn which areas to explore next.
- Validate. Check the winning settings on data the model has not seen, so you are not just fitting noise.
How it’s used in SEO and marketing
Most SEO projects tune a handful of familiar settings:
- LDA: the number of topics, the number of passes, and alpha (document-topic density) and beta (topic-word density).
- BERTopic: HDBSCAN’s
min_cluster_sizeandmin_samples, UMAP’sn_neighborsandn_components, and the embedding model. - K-means: the number of clusters, often chosen with the elbow method or silhouette scores.
- Fuzzy matching: the similarity threshold above which a match is accepted.
- Classifiers: settings such as regularisation strength in logistic regression.
Example
In MLforSEO’s LDA walkthrough, a first run on site content returns topics that blur together and a disappointing coherence score. Too high an alpha spreads too many topics across each document, and too high a beta mixes too many words into each topic. Lowering them and testing a few values for the number of topics produces fewer, sharper topics with a higher coherence score. With BERTopic on the course demo data, raising min_cluster_size split a topic that had lumped two unrelated themes together.
Limitations and things to watch
- Tuning can overfit to one dataset. Re-check settings when your data changes.
- Higher metric scores do not guarantee usable topics or clusters; always read the output.
- Large grid searches can be slow and, with paid APIs, costly. Start with the two or three settings that matter most.
- Fix random seeds while tuning, or you will not know whether a change came from the setting or from chance.
Learn it on MLforSEO
- Topic Modelling for SEO with LDA (Latent Dirichlet Allocation)
- Topic Modelling for SEO with BERTopic
- Web Content Clustering: Topic Modeling with LDA (Notebook)
- The Introduction to Machine Learning for SEO course, which tunes LDA and BERTopic in its clustering practicals
Where Hyperparameter Tuning shows up on MLforSEO
Learn it in a course
Sources and further reading
Other terms from Core Concepts (AI/ML)
- AlgorithmA defined set of steps for solving a problem; in machine learning, the procedure that learns patterns from dat…
- Artificial Intelligence (AI)The broad field of building systems that appear to reason, learn and act intelligently; machine learning is on…
- Bag of WordsA simple way to turn text into numbers by counting how often each word appears in a document, ignoring grammar…
- Bias (AI/ML)When a model systematically favours some outcomes or groups over others because of skewed data, labels, design…
- Data Labelling (Annotation)Adding the correct answer (a category, entity, sentiment or score) to examples, so a supervised model can lear…
- Data Preprocessing (Cleaning)Cleaning, fixing and reshaping raw data so a machine learning model or analysis can use it, from removing dupl…
- Deep LearningA branch of machine learning that trains many-layered neural networks on large datasets; it powers modern lang…
- Dimensionality ReductionCompressing data with many features, such as embeddings, into fewer dimensions while keeping the important str…
- EmbeddingA list of numbers (a vector) that represents the meaning of a word, text, image or entity, so similar things s…
