We have this overload for CreateTextLoader<TInput>, where the schema is defined in TInput.
|
public static TextLoader CreateTextLoader<TInput>(this DataOperationsCatalog catalog, |
|
char separatorChar = TextLoader.Defaults.Separator, |
|
bool hasHeader = TextLoader.Defaults.HasHeader, |
|
IMultiStreamSource dataSample = null, |
|
bool allowQuoting = TextLoader.Defaults.AllowQuoting, |
|
bool trimWhitespace = TextLoader.Defaults.TrimWhitespace, |
|
bool allowSparse = TextLoader.Defaults.AllowSparse) |
|
=> TextLoader.CreateTextLoader<TInput>(CatalogUtils.GetEnvironment(catalog), hasHeader, separatorChar, allowQuoting, |
|
allowSparse, trimWhitespace, dataSample: dataSample); |
The dataSample argument is meant to be used to infer schema. Since TInput must contain at least one field, there is always at least one column in the schema. Then, this condition is never hit, and consequently, dataSample is never used to infer the schema with the CreateTextLoader<TInput> overload.
|
if (Utils.Size(cols) == 0 && !TryParseSchema(_host, headerFile ?? dataSample, ref options, out cols, out error)) |
Presence of the dataSample argument is confusing here as it implies that a sample can be provided. In other places, this sample is used to infer schema, so the user would expect this to be the case here as well, but dataSample is ignored here.
I will update the documentation to reflect this, but this should be removed. Since this will be an API breaking change, this should be revisited for 2.0.
We have this overload for
CreateTextLoader<TInput>, where the schema is defined inTInput.machinelearning/src/Microsoft.ML.Data/DataLoadSave/Text/TextLoaderSaverCatalog.cs
Lines 90 to 98 in c3d1592
The
dataSampleargument is meant to be used to infer schema. SinceTInputmust contain at least one field, there is always at least one column in the schema. Then, this condition is never hit, and consequently,dataSampleis never used to infer the schema with theCreateTextLoader<TInput>overload.machinelearning/src/Microsoft.ML.Data/DataLoadSave/Text/TextLoader.cs
Line 1118 in c3d1592
Presence of thedataSampleargument is confusing here as it implies that a sample can be provided. In other places, this sample is used to infer schema, so the user would expect this to be the case here as well, butdataSampleis ignored here.I will update the documentation to reflect this, but this should be removed. Since this will be an API breaking change, this should be revisited for 2.0.