-
Notifications
You must be signed in to change notification settings - Fork 0
Text 0.5.0 hashingvectorizer save
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.
Write the options out, which is all there is to write.
public void Save(Stream destination)
public void Save(string path)Parameters — destination is a writable stream, left open for the caller to dispose; path
is a file to create or overwrite.
Exceptions — ArgumentNullException for a null stream or path. IOException from the stream
or file system.
Example — a round trip that carries the settings and nothing else.
using Lodestar.Text.Vectorization;
var hv = new HashingVectorizer(new HashingVectorizerOptions { NumFeatures = 16 });
using var buffer = new MemoryStream();
hv.Save(buffer);
buffer.Position = 0;
HashingVectorizer restored = HashingVectorizer.Load(buffer);
int columns = restored.NumFeatures; // => 16Remarks — there is no fit to save, so this writes the options alone, and unlike its counterparts it never throws for being unfitted — there is no such state.
Whether it is worth saving at all is a fair question, and the answer is that it keeps the three vectorizers interchangeable: code that persists a fitted model works unchanged when the model is this one. The file is small.
Applies to — net10.0, netstandard2.0.
See also — HashingVectorizer.Load,
HashingVectorizer.SaveAsync.