Text tfidfvectorizer getfeaturenames - CyrilB1531/lodestar GitHub Wiki

Development build. This page describes main, not a released package. The latest published Lodestar.Text is 0.6.0 — read its documentation.

HomeTextVectorization

TfidfVectorizer.GetFeatureNames

The term each column stands for, in column order.

public IReadOnlyList<string> GetFeatureNames()

ReturnsIReadOnlyList<string> of length ColumnCount, sorted, where index i names the term weighted by column i.

ExceptionsInvalidOperationException when nothing has been fitted yet.

Example — the names, and the weight beside them.

using Lodestar.Abstractions;
using Lodestar.Text.Vectorization;

var tv = new TfidfVectorizer();
CsrMatrix weighted = tv.FitTransform(["the cat eats", "the dog eats", "the cat and the dog"]);

IReadOnlyList<string> names = tv.GetFeatureNames();
string first = names[0];  // => and

Remarks — the vocabulary is sorted and shared with the count half, so this returns exactly what CountVectorizer.GetFeatureNames would over the same corpus and options. Pairing it with Idf is how to see which terms the weighting considered rare.

HashingVectorizer has no counterpart, because it keeps no vocabulary to name.

Applies to — net10.0, netstandard2.0.

See alsoTfidfVectorizer, CountVectorizer.GetFeatureNames.

⚠️ **GitHub.com Fallback** ⚠️