Search Intent Classification from SERP Features in Python: Rule-Based Notebook for SEO
Search intent classification often gets stuck at the keyword level, but the real signals live in the SERP itself. This Google Colab notebook by Lazarina Stoy, part of the Semantic AI-powered SEO Keyword Research course, gives you a complete rule-based system that classifies search intent directly from SERP features—no API keys, no transformer models, no machine learning training required. Just upload a CSV with your keywords and SERP features (from any rank tracker like Semrush, Ahrefs, or DataForSEO) and let the script do the rest.
The notebook runs three connected functions that build on each other. The first maps over 60 SERP features—from AI Overview and Answer Box to Shopping Results, Local Pack, and Carousel—to one of four intent categories: Informational, Navigational, Transactional, or Commercial Investigation. The second function calculates the percentage breakdown of each intent category per keyword, so instead of a single label you get a full distribution showing how mixed-intent SERPs really are. The third function classifies the top-ranking domains across 20 site type rules (Wiki, News, Reviews, E-commerce, Social Media, Government/Education, Health, Travel, Jobs, Finance, Maps/Navigation, Developer Platforms, and more) and maps them to holistic intent categories, then joins this lookup back to your full SERP results so every URL gets an intent label based on which type of site is ranking.
Use this for:
‧ Classifying search intent at scale without paying for API calls or running ML models
‧ Getting percentage-based intent breakdowns instead of forced single-label classifications, revealing mixed-intent opportunities
‧ Mapping ranking domains to holistic intent categories to understand which types of sites Google rewards for each query
‧ Building a foundational SERP analysis layer you can extend with your own SERP features, domain rules, and intent definitions
‧ Auditing keyword sets quickly to prioritize content investments based on dominant SERP intent signals
This is perfect for SEO professionals, content strategists, and keyword researchers who want a transparent, fully customizable, zero-cost way to add search intent classification to their workflow—no machine learning experience needed.
What’s included
- Three connected classification functions in one notebook: SERP-feature-to-intent mapping, percentage breakdowns across four intent categories, and domain-level intent classification using 20+ site type rules
- Maps 60+ SERP features (AI Overview, Featured Snippet, Shopping Results, Local Pack, People Also Ask, and more) to Informational, Navigational, Transactional, or Commercial Investigation intent—fully editable to match your own taxonomy
- Pure Python with pandas and regex—no API keys, no GPU, no transformer downloads, no recurring costs—just upload your CSV and download the enriched results
Where this resource is used on MLforSEO
Used in the course
Walkthroughs on the blog
Concepts behind it
More search intent resources
- Coding Script or NotebookMulti-Dimension Query Classifier: Rule-Based Colab Notebook and Google Sheets Template
- Coding Script or NotebookSemantic Search Intent Classification with Google Cloud NLP & spaCy in Python (Colab Notebook)
- Coding Script or NotebookTransformer-Based Search Intent Classification with BART Zero-Shot & SERP Signals (Colab Notebook)
- Coding Script or NotebookSynthetic vs User Query Classification Notebook with Rule-Based and Machine Learning Detection
- Coding Script or NotebookIdentifying Desired Content Formats & Platforms from SERP Data (Lab Notebook)
- No-Code TemplateKeyword Mapping Template with Intent and Cannibalisation Flags (Google Sheets)
See all 11 search intent resources →See all 42 coding script or notebook resources →


