Skip to content

Rename Save API for DataLoader to SaveDataLoader. #3019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Microsoft.ML.Data/Model/ModelOperationsCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal ModelOperationsCatalog(IHostEnvironment env)
/// </summary>
/// <param name="model">The trained model to be saved.</param>
/// <param name="stream">A writeable, seekable stream to save to.</param>
public void Save<TSource>(IDataLoader<TSource> model, Stream stream)
public void SaveDataLoader<TSource>(IDataLoader<TSource> model, Stream stream)
{
_env.CheckValue(model, nameof(model));
_env.CheckValue(stream, nameof(stream));
Expand All @@ -50,10 +50,10 @@ public void Save<TSource>(IDataLoader<TSource> model, Stream stream)
/// </summary>
/// <param name="model">The trained model to be saved.</param>
/// <param name="filePath">Path where model should be saved.</param>
public void Save<TSource>(IDataLoader<TSource> model, string filePath)
public void SaveDataLoader<TSource>(IDataLoader<TSource> model, string filePath)
{
using (var stream = File.Create(filePath))
Save(model, stream);
SaveDataLoader(model, stream);
}

/// <summary>
Expand All @@ -63,7 +63,7 @@ public void Save<TSource>(IDataLoader<TSource> model, string filePath)
/// <param name="model">The trained model to be saved</param>
/// <param name="stream">A writeable, seekable stream to save to.</param>
public void Save<TSource>(IDataLoader<TSource> loader, ITransformer model, Stream stream) =>
Save(new CompositeDataLoader<TSource, ITransformer>(loader, new TransformerChain<ITransformer>(model)), stream);
SaveDataLoader(new CompositeDataLoader<TSource, ITransformer>(loader, new TransformerChain<ITransformer>(model)), stream);

/// <summary>
/// Save a transformer model and the loader used to create its input data to the file.
Expand Down
6 changes: 3 additions & 3 deletions test/Microsoft.ML.Functional.Tests/ModelLoading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void LoadModelAndExtractPredictor()
string modelAndSchemaPath = GetOutputPath(FullTestName + "-model-schema.zip");
_ml.Model.Save(transformerModel, data.Schema, modelAndSchemaPath);
string compositeLoaderModelPath = GetOutputPath(FullTestName + "-composite-model.zip");
_ml.Model.Save(compositeLoaderModel, compositeLoaderModelPath);
_ml.Model.SaveDataLoader(compositeLoaderModel, compositeLoaderModelPath);
string loaderAndTransformerModelPath = GetOutputPath(FullTestName + "-loader-transformer.zip");
_ml.Model.Save(loader, transformerModel, loaderAndTransformerModelPath);

Expand Down Expand Up @@ -190,7 +190,7 @@ public void SaveTextLoaderAndLoad()
var loader = _ml.Data.CreateTextLoader<InputData>(hasHeader: true, dataSample: file);

string modelPath = GetOutputPath(FullTestName + "-model.zip");
_ml.Model.Save(loader, modelPath);
_ml.Model.SaveDataLoader(loader, modelPath);

Load(modelPath, out var loadedWithSchema, out var loadedSchema, out var loadedLoader,
out var loadedWithLoader, out var loadedLoaderWithTransformer);
Expand Down Expand Up @@ -220,7 +220,7 @@ public void SaveCompositeLoaderAndLoad()
var model = composite.Fit(file);

string modelPath = GetOutputPath(FullTestName + "-model.zip");
_ml.Model.Save(model, modelPath);
_ml.Model.SaveDataLoader(model, modelPath);

Load(modelPath, out var loadedWithSchema, out var loadedSchema, out var loadedLoader,
out var loadedWithLoader, out var loadedLoaderWithTransformer);
Expand Down