Skip to content

Text 0.4.0 tfidfvectorizer load

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.

TfidfVectorizer.Load

Read a fitted vectorizer back.

public static TfidfVectorizer Load(Stream source, ArtifactLoadOptions options = null)
public static TfidfVectorizer Load(string path, ArtifactLoadOptions options = null)

Parameterssource is a readable stream, left open; path is a file to read. options bounds what will be accepted and defaults to ArtifactLoadOptions's own defaults.

ReturnsTfidfVectorizer, fitted and ready to Transform.

ExceptionsArgumentNullException for a null source. InvalidDataException when the content is not a saved vectorizer, or exceeds a bound in options.

Example — the vocabulary comes back in the order it was saved.

using Lodestar.Text.Vectorization;

var original = new TfidfVectorizer();
original.Fit(["the cat eats", "the dog eats"]);

using var buffer = new MemoryStream();
original.Save(buffer);
buffer.Position = 0;

TfidfVectorizer restored = TfidfVectorizer.Load(buffer);
string first = restored.GetFeatureNames()[0];  // => cat

Remarksoptions is what stands between a file and an allocation: a saved vectorizer declaring a hundred million vocabulary entries would otherwise be believed. Bounds are refused rather than truncated, so an oversized file is an error rather than a quietly smaller model.

Applies to — net10.0, netstandard2.0.

See alsoTfidfVectorizer.Save, ArtifactLoadOptions.

Lodestar

Project

Clone this wiki locally