Task Types

Text Classification

In shortA machine learning task that sorts text such as pages, keywords or reviews into predefined categories, learned from labelled examples.

Updated 24 Oct 2026· 3 min read

Text classification is the machine learning task of sorting pieces of text into categories you have defined in advance. A model learns patterns from labelled examples (emails marked spam or not spam, pages tagged by topic) and then assigns a label to new text it has never seen. It is a form of supervised learning, and in SEO it is the quiet workhorse behind page tagging, intent labelling and content audits.

How it works

Every text classifier needs three things: a set of categories, examples of text that belong to each, and a model that learns to tell them apart. Classic models such as Naive Bayes, decision trees or support vector machines work on word counts or TF-IDF scores, while modern models use embeddings or transformer networks that capture meaning and context. For each item the model returns a label and usually a confidence score, which tells you how sure it is.

The task comes in several shapes. Binary classification picks one of two outcomes, multi-class classification picks one of three or more, and multi-label classification assigns several labels at once, for example a broad topic plus a narrower subtopic. You can train your own model, or use a pre-trained one such as the content classification module of the Google Cloud Natural Language API, which maps a document to a hierarchical taxonomy of categories like /Arts & Entertainment or /Finance.

How it’s used in SEO and marketing

  • Labelling pages by topic or page type during a content audit, so you can see where coverage is thin.
  • Search intent classification: tagging keywords as informational, commercial, transactional or navigational.
  • Sorting reviews, support tickets or social comments by theme, alongside sentiment analysis.
  • Flagging risky or off-brand content, which is the idea behind content moderation.
  • Understanding how search engines group content: MLforSEO’s guide to query and session context links the broad macro-context of a query to the kind of categories Google’s own classification API returns.

Example

In the Introduction to ML for SEO course, page content from a site is scraped with Screaming Frog, pasted into Google Sheets and sent to the Natural Language API’s classifyText method through Apps Script. Each row comes back with a category such as /Business & Industrial/Advertising & Marketing and a confidence score. Within minutes you have a topic map of the whole site that you can pivot in Looker Studio, with no code written.

Limitations and things to watch

  • You can only get labels you defined (or that the pre-trained taxonomy contains). If you want the data to reveal its own groups, use clustering instead.
  • Imbalanced data skews results: a model trained mostly on one class tends to over-predict it.
  • Short texts such as single keywords give the model little to work with. Google’s API needs at least 20 tokens for the V1 model, so page-level text works better than queries.
  • Generic taxonomies rarely match your business categories. Check a labelled sample and treat low-confidence labels as “needs review”.
  • Generative AI can classify text, but MLforSEO’s tests show purpose-built NLP models are more consistent for structured labelling (see the comparison).

Learn it on MLforSEO

Where Text Classification shows up on MLforSEO

Sources and further reading

Other terms from Task Types

See all 13 Task Types terms →