Skip to content

Text 0.4.0 hashingvectorizer fittransform

github-actions[bot] edited this page Aug 21, 2026 · 1 revision

Lodestar.Text 0.4.0. This page is frozen at that release. Read the current documentation for what main says now. A link to a decision or a migration page follows main, and leaves the archive.

HashingVectorizer.FitTransform

The same as Transform — there is nothing to fit.

public CsrMatrix FitTransform(IEnumerable<string> documents)

Parametersdocuments is the corpus to vectorize.

ReturnsCsrMatrix, identical to what Transform returns for the same input.

ExceptionsArgumentNullException when documents is null.

Example — the two calls agree, which is the whole content of this member.

using Lodestar.Text.Vectorization;

string[] docs = ["the cat eats", "the dog eats"];
var hv = new HashingVectorizer(new HashingVectorizerOptions { NumFeatures = 16 });

CsrMatrix fitted = hv.FitTransform(docs);
CsrMatrix transformed = hv.Transform(docs);

bool same = fitted.NonZeroCount == transformed.NonZeroCount;  // => True

Remarks — it exists so that the three vectorizers can be swapped for one another without the calling code changing shape. Code written against FitTransform works with all three; code that also calls Fit does not, because this type has none.

scikit-learn's HashingVectorizer carries a fit for the same reason — its pipeline API requires one — and it likewise does nothing.

Applies to — net10.0, netstandard2.0.

See alsoHashingVectorizer.Transform, CountVectorizer.FitTransform.

Lodestar

Project

Clone this wiki locally