Text 0.5.0 hashingvectorizer fittransform - CyrilB1531/lodestar GitHub Wiki
Lodestar.Text 0.5.0. This page is frozen at that release. Read the current documentation for what
mainsays now. A link to a decision or a migration page followsmain, and leaves the archive.
The same as Transform — there is nothing to fit.
public CsrMatrix FitTransform(IEnumerable<string> documents)Parameters — documents is the corpus to vectorize.
Returns — CsrMatrix, identical to what
Transform returns for the same input.
Exceptions — ArgumentNullException when documents is null.
Example — the two calls agree, which is the whole content of this member.
using Lodestar.Abstractions;
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; // => TrueRemarks — 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 also — HashingVectorizer.Transform,
CountVectorizer.FitTransform.