BinaryVectorizer<T>
Models & Types ยท AiDotNet.Preprocessing.TextVectorizers
Converts text documents to binary feature vectors (presence/absence encoding).
Inheritance: TextVectorizerBase<T> โ BinaryVectorizer<T>
For Beginners
Binary encoding is the simplest text representation:
- Each word is either present (1) or absent (0) in a document
- Word frequency is ignored (appearing 10 times = appearing once)
- Fast and memory-efficient
- Works well when word presence matters more than frequency
- Common in document classification and spam detection
How It Works
BinaryVectorizer creates a simple presence/absence encoding where each feature is 1 if the term appears in the document and 0 otherwise. Unlike CountVectorizer with binary=true, this vectorizer is optimized specifically for binary encoding.
Constructors
| Constructor | Summary |
|---|---|
BinaryVectorizer(int minDf, double maxDf, int? maxFeatures, ValueTuple<int, int>? nGramRange, bool lowercase, Func<string, IEnumerable<string>> tokenizer, HashSet<string> stopWords, ITokenizer advancedTokenizer) |
Creates a new instance of BinaryVectorizer. |
Methods
| Method | Summary |
|---|---|
Matrix<T> Transform(IEnumerable<string> documents) |
Transforms documents to binary vectors. |
void Fit(IEnumerable<string> documents) |
Fits the vectorizer to the corpus. |