Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Scikit learn Scikit learn StopWords

From Leeroopedia
Revision as of 16:37, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Scikit_learn_Scikit_learn_StopWords.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Natural Language Processing, Text Preprocessing
Last Updated 2026-02-08 15:00 GMT

Overview

Concrete tool providing a predefined set of English stop words for text feature extraction provided by scikit-learn.

Description

The _stop_words module defines ENGLISH_STOP_WORDS, a frozenset of common English stop words sourced from the Glasgow Information Retrieval Group. Stop words are common words (such as "the", "a", "is", "in") that are typically filtered out during text preprocessing because they carry little meaningful information for text analysis tasks. This set is used internally by scikit-learn text vectorizers when stop_words='english' is specified.

Usage

Use the ENGLISH_STOP_WORDS set when you need a standard list of English stop words for text preprocessing, or when configuring CountVectorizer or TfidfVectorizer with the stop_words='english' parameter. It can also be extended or customized as needed for domain-specific applications.

Code Reference

Source Location

Signature

ENGLISH_STOP_WORDS = frozenset([
    "a", "about", "above", "across", "after", "afterwards", "again", ...
])

Import

from sklearn.feature_extraction.text import ENGLISH_STOP_WORDS

I/O Contract

Inputs

Name Type Required Description
(none) N/A N/A ENGLISH_STOP_WORDS is a constant frozenset; it takes no inputs.

Outputs

Name Type Description
ENGLISH_STOP_WORDS frozenset of str A set of 318 common English stop words from the Glasgow Information Retrieval Group.

Usage Examples

Basic Usage

from sklearn.feature_extraction.text import ENGLISH_STOP_WORDS

# Check if a word is a stop word
print("the" in ENGLISH_STOP_WORDS)  # True
print("python" in ENGLISH_STOP_WORDS)  # False

# Use with CountVectorizer
from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer(stop_words='english')
X = vectorizer.fit_transform(["This is a sample document about python"])
print(vectorizer.get_feature_names_out())
# Words like 'this', 'is', 'a' will be filtered out

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment