Skip to content

Rename IDataLoader, IDataReader and IDataReaderEstimator #2731

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

Merged
merged 13 commits into from
Feb 27, 2019
Merged
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
148 changes: 74 additions & 74 deletions docs/code/MlNetCookBook.md

Large diffs are not rendered by default.

194 changes: 97 additions & 97 deletions docs/code/experimental/MlNetCookBookStaticApi.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/samples/Microsoft.ML.Samples/Dynamic/Calibrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void Example()
var mlContext = new MLContext();

// Create a text loader.
var reader = mlContext.Data.CreateTextLoader(new TextLoader.Options()
var loader = mlContext.Data.CreateTextLoader(new TextLoader.Options()
{
Separators = new[] { '\t' },
HasHeader = true,
Expand All @@ -39,8 +39,8 @@ public static void Example()
}
});

// Read the data
var data = reader.Read(dataFile);
// Load the data
var data = loader.Load(dataFile);

// Split the dataset into two parts: one used for training, the other to train the calibrator
var split = mlContext.BinaryClassification.TrainTestSplit(data, testFraction: 0.1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void Example()

// Get a small dataset as an IEnumerable and them read it as ML.NET's data type.
IEnumerable<SamplesUtils.DatasetUtils.BinaryLabelFloatFeatureVectorSample> enumerableOfData = SamplesUtils.DatasetUtils.GenerateBinaryLabelFloatFeatureVectorSamples(5);
var data = mlContext.Data.ReadFromEnumerable(enumerableOfData);
var data = mlContext.Data.LoadFromEnumerable(enumerableOfData);

// Look at the original dataset
Console.WriteLine($"Label\tFeatures[0]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public static void Example()
// Get a small dataset as an IEnumerable.
IEnumerable<DatasetUtils.SampleTemperatureData> enumerableOfData = DatasetUtils.GetSampleTemperatureData(5);

// Read in into an IDataView using ReadFromEnumerable.
IDataView data = mlContext.Data.ReadFromEnumerable(enumerableOfData);
// Load dataset into an IDataView.
IDataView data = mlContext.Data.LoadFromEnumerable(enumerableOfData);

// We can now examine the records in the IDataView. We first create an enumerable of rows in the IDataView.
var rowEnumerable = mlContext.Data.CreateEnumerable<DatasetUtils.SampleTemperatureData>(data, reuseRowObject: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void Example()

// Get a small dataset as an IEnumerable.
IEnumerable<SamplesUtils.DatasetUtils.SampleTemperatureData> enumerableOfData = SamplesUtils.DatasetUtils.GetSampleTemperatureData(10);
var data = mlContext.Data.ReadFromEnumerable(enumerableOfData);
var data = mlContext.Data.LoadFromEnumerable(enumerableOfData);

// Before we apply a filter, examine all the records in the dataset.
Console.WriteLine($"Date\tTemperature");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void Example()

// Get a small dataset as an IEnumerable.
IEnumerable<MulticlassClassificationExample> enumerableOfData = DatasetUtils.GenerateRandomMulticlassClassificationExamples(10);
var data = mlContext.Data.ReadFromEnumerable(enumerableOfData);
var data = mlContext.Data.LoadFromEnumerable(enumerableOfData);

// Convert the string labels to keys
var pipeline = mlContext.Transforms.Conversion.MapValueToKey("Label");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void Example()

// Get a small dataset as an IEnumerable.
var dataEnumerable = DatasetUtils.GenerateFloatLabelFloatFeatureVectorSamples(10, naRate: 0.05);
var data = mlContext.Data.ReadFromEnumerable(dataEnumerable);
var data = mlContext.Data.LoadFromEnumerable(dataEnumerable);

// Look at the original dataset
Console.WriteLine($"Label\tFeatures");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void Example()

// Get a small dataset as an IEnumerable.
var enumerableOfData = DatasetUtils.GetSampleTemperatureData(5);
var data = mlContext.Data.ReadFromEnumerable(enumerableOfData);
var data = mlContext.Data.LoadFromEnumerable(enumerableOfData);

// Before we apply a filter, examine all the records in the dataset.
Console.WriteLine($"Date\tTemperature");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void Example()

// Get a small dataset as an IEnumerable.
var enumerableOfData = SamplesUtils.DatasetUtils.GetSampleTemperatureData(10);
var data = mlContext.Data.ReadFromEnumerable(enumerableOfData);
var data = mlContext.Data.LoadFromEnumerable(enumerableOfData);

// Before we apply a filter, examine all the records in the dataset.
Console.WriteLine($"Date\tTemperature");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void Example()

// Get a small dataset as an IEnumerable.
var enumerableOfData = SamplesUtils.DatasetUtils.GetSampleTemperatureData(10);
var data = mlContext.Data.ReadFromEnumerable(enumerableOfData);
var data = mlContext.Data.LoadFromEnumerable(enumerableOfData);

// Before we apply a filter, examine all the records in the dataset.
Console.WriteLine($"Date\tTemperature");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void Example()

// Get a small dataset as an IEnumerable and convert it to an IDataView.
var data = SamplesUtils.DatasetUtils.GetInfertData();
var trainData = ml.Data.ReadFromEnumerable(data);
var trainData = ml.Data.LoadFromEnumerable(data);

// Preview of the data.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public static void Example()
// as well as the source of randomness.
var ml = new MLContext();

// First, we define the reader: specify the data columns and where to find them in the text file. Notice that we combine entries from
// First, we define the loader: specify the data columns and where to find them in the text file. Notice that we combine entries from
// all the feature columns into entries of a vector of a single column named "Features".
var reader = ml.Data.CreateTextLoader(
var loader = ml.Data.CreateTextLoader(
columns: new[]
{
new TextLoader.Column("Label", DataKind.Boolean, 0),
Expand All @@ -39,8 +39,8 @@ public static void Example()
hasHeader: true
);

// Then, we use the reader to read the data as an IDataView.
var data = reader.Read(dataFilePath);
// Then, we use the loader to load the data as an IDataView.
var data = loader.Load(dataFilePath);

// Second, we define the transformations that we apply on the data. Remember that an Estimator does not transform data
// directly, but it needs to be trained on data using .Fit(), and it will output a Transformer, which can transform data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void IidChangePointDetectorTransform()
data.Add(new IidChangePointData(7));

// Convert data to IDataView.
var dataView = ml.Data.ReadFromEnumerable(data);
var dataView = ml.Data.LoadFromEnumerable(data);

// Setup IidSpikeDetector arguments
string outputColumnName = nameof(ChangePointPrediction.Prediction);
Expand Down Expand Up @@ -104,7 +104,7 @@ public static void IidChangePointDetectorPrediction()
data.Add(new IidChangePointData(7));

// Convert data to IDataView.
var dataView = ml.Data.ReadFromEnumerable(data);
var dataView = ml.Data.LoadFromEnumerable(data);

// Setup IidSpikeDetector arguments
string outputColumnName = nameof(ChangePointPrediction.Prediction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void IidSpikeDetectorTransform()
data.Add(new IidSpikeData(5));

// Convert data to IDataView.
var dataView = ml.Data.ReadFromEnumerable(data);
var dataView = ml.Data.LoadFromEnumerable(data);

// Setup IidSpikeDetector arguments
string outputColumnName = nameof(IidSpikePrediction.Prediction);
Expand Down Expand Up @@ -93,7 +93,7 @@ public static void IidSpikeDetectorPrediction()
data.Add(new IidSpikeData(5));

// Convert data to IDataView.
var dataView = ml.Data.ReadFromEnumerable(data);
var dataView = ml.Data.LoadFromEnumerable(data);

// Setup IidSpikeDetector arguments
string outputColumnName = nameof(IidSpikePrediction.Prediction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void Example()
new TextLoader.Column("ImagePath", DataKind.String, 0),
new TextLoader.Column("Name", DataKind.String, 1),
}
}).Read(imagesDataFile);
}).Load(imagesDataFile);

var imagesFolder = Path.GetDirectoryName(imagesDataFile);
// Image loading pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void Example()
new TextLoader.Column("ImagePath", DataKind.String, 0),
new TextLoader.Column("Name", DataKind.String, 1),
}
}).Read(imagesDataFile);
}).Load(imagesDataFile);

var imagesFolder = Path.GetDirectoryName(imagesDataFile);
// Image loading pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void Example()
new TextLoader.Column("ImagePath", DataKind.String, 0),
new TextLoader.Column("Name", DataKind.String, 1),
}
}).Read(imagesDataFile);
}).Load(imagesDataFile);

var imagesFolder = Path.GetDirectoryName(imagesDataFile);
// Image loading pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void Example()
new TextLoader.Column("ImagePath", DataKind.String, 0),
new TextLoader.Column("Name", DataKind.String, 1),
}
}).Read(imagesDataFile);
}).Load(imagesDataFile);

var imagesFolder = Path.GetDirectoryName(imagesDataFile);
// Image loading pipeline.
Expand Down
2 changes: 1 addition & 1 deletion docs/samples/Microsoft.ML.Samples/Dynamic/KMeans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static void Example()

// Get a small dataset as an IEnumerable and convert it to an IDataView.
var data = SamplesUtils.DatasetUtils.GetInfertData();
var trainData = ml.Data.ReadFromEnumerable(data);
var trainData = ml.Data.LoadFromEnumerable(data);

// Preview of the data.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void Example()

// Get a small dataset as an IEnumerable and load it into ML.NET data set.
IEnumerable<SamplesUtils.DatasetUtils.SampleTopicsData> data = SamplesUtils.DatasetUtils.GetTopicsData();
var trainData = ml.Data.ReadFromEnumerable(data);
var trainData = ml.Data.LoadFromEnumerable(data);

// Preview of one of the columns of the the topics data.
// The Review column contains the keys associated with a particular body of text.
Expand Down
2 changes: 1 addition & 1 deletion docs/samples/Microsoft.ML.Samples/Dynamic/LdaTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void Example()

// Get a small dataset as an IEnumerable and then read it as a ML.NET data set.
IEnumerable<SamplesUtils.DatasetUtils.SampleTopicsData> data = SamplesUtils.DatasetUtils.GetTopicsData();
var trainData = ml.Data.ReadFromEnumerable(data);
var trainData = ml.Data.LoadFromEnumerable(data);

// Preview of one of the columns of the the topics data.
// The Review column contains the keys associated with a particular body of text.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void Example()
// 14. Column: native-country (text/categorical)
// 15. Column: Column [Label]: IsOver50K (boolean)

var reader = ml.Data.CreateTextLoader(new TextLoader.Options
var loader = ml.Data.CreateTextLoader(new TextLoader.Options
{
Separators = new[] { ',' },
HasHeader = true,
Expand All @@ -55,7 +55,7 @@ public static void Example()
}
});

IDataView data = reader.Read(dataFilePath);
IDataView data = loader.Load(dataFilePath);

var split = ml.BinaryClassification.TrainTestSplit(data, testFraction: 0.2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void NgramTransform()

// Get a small dataset as an IEnumerable and convert to IDataView.
IEnumerable<SamplesUtils.DatasetUtils.SampleSentimentData> data = SamplesUtils.DatasetUtils.GetSentimentData();
var trainData = ml.Data.ReadFromEnumerable(data);
var trainData = ml.Data.LoadFromEnumerable(data);

// Preview of the data.
//
Expand Down
2 changes: 1 addition & 1 deletion docs/samples/Microsoft.ML.Samples/Dynamic/Normalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void Example()

// Get a small dataset as an IEnumerable and convert it to an IDataView.
IEnumerable<SamplesUtils.DatasetUtils.SampleInfertData> data = SamplesUtils.DatasetUtils.GetInfertData();
var trainData = ml.Data.ReadFromEnumerable(data);
var trainData = ml.Data.LoadFromEnumerable(data);

// Preview of the data.
//
Expand Down
2 changes: 1 addition & 1 deletion docs/samples/Microsoft.ML.Samples/Dynamic/OnnxTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void Example()
// Create ML pipeline to score the data using OnnxScoringEstimator
var mlContext = new MLContext();
var data = GetTensorData();
var idv = mlContext.Data.ReadFromEnumerable(data);
var idv = mlContext.Data.LoadFromEnumerable(data);
var pipeline = mlContext.Transforms.ApplyOnnxModel(modelPath, new[] { outputInfo.Key }, new[] { inputInfo.Key });

// Run the pipeline and get the transformed values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void Example()

// Get a small dataset as an IEnumerable and convert it to an IDataView.
IEnumerable<SamplesUtils.DatasetUtils.SampleVectorOfNumbersData> data = SamplesUtils.DatasetUtils.GetVectorOfNumbersData();
var trainData = ml.Data.ReadFromEnumerable(data);
var trainData = ml.Data.LoadFromEnumerable(data);

// Preview of the data.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void Example()

// Get a small dataset as an IEnumerable and convert it to an IDataView.
var data = SamplesUtils.DatasetUtils.GetInfertData();
var trainData = ml.Data.ReadFromEnumerable(data);
var trainData = ml.Data.LoadFromEnumerable(data);

// Preview of the data.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void SsaChangePointDetectorTransform()
data.Add(new SsaChangePointData(i * 100));

// Convert data to IDataView.
var dataView = ml.Data.ReadFromEnumerable(data);
var dataView = ml.Data.LoadFromEnumerable(data);

// Setup SsaChangePointDetector arguments
var inputColumnName = nameof(SsaChangePointData.Value);
Expand Down Expand Up @@ -102,7 +102,7 @@ public static void SsaChangePointDetectorPrediction()
data.Add(new SsaChangePointData(j));

// Convert data to IDataView.
var dataView = ml.Data.ReadFromEnumerable(data);
var dataView = ml.Data.LoadFromEnumerable(data);

// Setup SsaChangePointDetector arguments
var inputColumnName = nameof(SsaChangePointData.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void SsaSpikeDetectorTransform()
data.Add(new SsaSpikeData(i));

// Convert data to IDataView.
var dataView = ml.Data.ReadFromEnumerable(data);
var dataView = ml.Data.LoadFromEnumerable(data);

// Setup IidSpikeDetector arguments
var inputColumnName = nameof(SsaSpikeData.Value);
Expand Down Expand Up @@ -110,7 +110,7 @@ public static void SsaSpikeDetectorPrediction()
data.Add(new SsaSpikeData(j));

// Convert data to IDataView.
var dataView = ml.Data.ReadFromEnumerable(data);
var dataView = ml.Data.LoadFromEnumerable(data);

// Setup IidSpikeDetector arguments
var inputColumnName = nameof(SsaSpikeData.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void Example()

// Get a small dataset as an IEnumerable and convert to IDataView.
var data = SamplesUtils.DatasetUtils.GetSentimentData();
var trainData = ml.Data.ReadFromEnumerable(data);
var trainData = ml.Data.LoadFromEnumerable(data);

// Preview of the data.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void Example()

var mlContext = new MLContext();
var data = GetTensorData();
var idv = mlContext.Data.ReadFromEnumerable(data);
var idv = mlContext.Data.LoadFromEnumerable(data);

// Create a ML pipeline.
var pipeline = mlContext.Transforms.ScoreTensorFlowModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public static void Example()
"such a big profile for the whole film but these children are amazing and should be praised " +
"for what they have done don't you think the whole story was so lovely because it was true " +
"and was someone's life after all that was shared with us all" } };
var dataView = mlContext.Data.ReadFromEnumerable(data);
var dataView = mlContext.Data.LoadFromEnumerable(data);

// This is the dictionary to convert words into the integer indexes.
var lookupMap = mlContext.Data.ReadFromTextFile(Path.Combine(modelLocation, "imdb_word_index.csv"),
var lookupMap = mlContext.Data.LoadFromTextFile(Path.Combine(modelLocation, "imdb_word_index.csv"),
columns: new[]
{
new TextLoader.Column("Words", DataKind.String, 0),
Expand Down
2 changes: 1 addition & 1 deletion docs/samples/Microsoft.ML.Samples/Dynamic/TextTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void Example()

// Get a small dataset as an IEnumerable and convert to IDataView.
var data = SamplesUtils.DatasetUtils.GetSentimentData();
var trainData = ml.Data.ReadFromEnumerable(data);
var trainData = ml.Data.LoadFromEnumerable(data);

// Preview of the data.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public static void Example()
// as a catalog of available operations and as the source of randomness.
var mlContext = new MLContext();

// Step 1: Read the data as an IDataView.
// First, we define the reader: specify the data columns and where to find them in the text file.
var reader = mlContext.Data.CreateTextLoader(
// Step 1: Load the data as an IDataView.
// First, we define the loader: specify the data columns and where to find them in the text file.
var loader = mlContext.Data.CreateTextLoader(
columns: new[]
{
new TextLoader.Column("Sentiment", DataKind.Boolean, 0),
Expand All @@ -34,8 +34,8 @@ public static void Example()
hasHeader: true
);

// Read the data
var data = reader.Read(dataFile);
// Load the data
var data = loader.Load(dataFile);

// ML.NET doesn't cache data set by default. Therefore, if one reads a data set from a file and accesses it many times, it can be slow due to
// expensive featurization and disk operations. When the considered data can fit into memory, a solution is to cache the data in memory. Caching is especially
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void Example()
var mlContext = new MLContext();

// Step 1: Read the data as an IDataView.
var data = mlContext.Data.ReadFromEnumerable(rawData);
var data = mlContext.Data.LoadFromEnumerable(rawData);

// ML.NET doesn't cache data set by default. Caching is always recommended when using the
// StochasticDualCoordinateAscent algorithm because it may incur multiple data passes.
Expand Down
Loading