Core Concepts (AI/ML)
Data Preprocessing (Cleaning)
In shortCleaning, fixing and reshaping raw data so a machine learning model or analysis can use it, from removing duplicates to tokenising text and scaling numbers.
Data preprocessing, often called data cleaning, is everything you do to raw data before it goes into a model or analysis. It removes errors, duplicates and noise, puts values into consistent formats, and converts the data into a shape the algorithm can work with. Every practical in MLforSEO’s courses has a preprocessing step, because the quality of the output depends on it more than on the choice of algorithm.
How it works
Typical steps depend on the type of data:
- General: remove duplicates and empty rows, fix encodings, standardise case and date formats, handle missing values (drop, fill or flag), and filter out rows that are out of scope.
- Text: strip HTML, URLs, emails and boilerplate; lowercase; remove punctuation and digits where they add nothing; remove stop words (including site-wide words such as your brand name, “menu” or “cookie”); tokenise; and apply lemmatisation or stemming.
- URLs: extract the slug or path, remove protocols, parameters and trailing slashes, and replace hyphens with spaces before comparing.
- Numbers: scale or normalise columns so large values do not dominate distance-based methods such as k-means, and deal with outliers.
Modern embedding models need lighter text cleaning than older methods such as LDA or TF-IDF, because they use context. Removing stop words before creating sentence embeddings can even hurt results.
How it’s used in SEO and marketing
- Topic modelling and clustering of page content, where navigation text and boilerplate otherwise become the “topics”.
- Redirect and 404 mapping, where cleaned URL slugs give far better fuzzy matches than raw URLs.
- Keyword research, where merging exports from several tools needs deduplication, normalised spelling and consistent intent labels.
- Customer and analytics data, where scaling and missing-value handling decide whether segments make sense.
Example
Before running LDA on a blog crawl, MLforSEO’s topic modelling code strips emails and URLs, removes standard stop words plus site-wide words like “cookie”, “menu” and the brand name, then tokenises and lemmatises the text. Without that step, “cookie” and “subscribe” would appear in nearly every topic and the coherence score would fall.
Limitations and things to watch
- Over-cleaning removes signal: dropping numbers, negations or short words can change meaning.
- Keep a copy of the raw data and document each step, so results can be reproduced and checked.
- Apply exactly the same preprocessing to new data that you applied to training data.
- Cleaning cannot fix data that was wrong or biased at collection.
Learn it on MLforSEO
Where Data Preprocessing (Cleaning) shows up on MLforSEO
Learn it in a course
Sources and further reading
- https://www.mlforseo.com/machine-learning-tutorials/topic-modeling-clustering/topic-modeling-for-seo-with-lda/ MLforSEO
- https://www.mlforseo.com/machine-learning-tutorials/fuzzy-matching/404-and-redirect-mapping-with-fuzzy-matching-in-google-colab-python/ MLforSEO
- https://www.mlforseo.com/machine-learning-tutorials/topic-modeling-clustering/what-ml-clustering-is-and-where-it-fits-in-seo/ MLforSEO
- scikit-learn: Preprocessing data
- Google Machine Learning Crash Course: Working with numerical data
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…
- 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…
- Explainable AI (Explainability)Explainable AI is the ability to understand and explain why a model produced a particular output, through inte…
