Skip to content

Text tfidfvectorizer getfeaturenames

github-actions[bot] edited this page Aug 28, 2026 · 28 revisions

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

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.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.

Lodestar

Project

Clone this wiki locally