dotnet/machinelearning · error · InferenceException
Unable to infer column types of the file provided.
Error message
Unable to infer column types of the file provided.
What it means
After splitting the file into columns, AutoML attempts to infer a ML.NET data type for each column. When the type inference result reports IsSuccess == false, InferColumnTypes throws this InferenceException (InferenceExceptionType.ColumnDataType), meaning it couldn't determine usable column types for the file. Usually a follow-on symptom of unparseable or empty data rather than a code bug.
Source
Thrown at src/Microsoft.ML.AutoML/ColumnInference/ColumnInferenceApi.cs:152
TextFileContents.ColumnSplitResult splitInference, bool hasHeader, uint? labelColumnIndex, string label)
{
// infer column types
var typeInferenceResult = ColumnTypeInference.InferTextFileColumnTypes(context, sample,
new ColumnTypeInference.Arguments
{
ColumnCount = splitInference.ColumnCount,
Separator = splitInference.Separator.Value,
AllowSparse = splitInference.AllowSparse,
AllowQuote = splitInference.AllowQuote,
ReadMultilines = splitInference.ReadMultilines,
HasHeader = hasHeader,
LabelColumnIndex = labelColumnIndex,
Label = label
});
if (!typeInferenceResult.IsSuccess)
{
throw new InferenceException(InferenceExceptionType.ColumnDataType, "Unable to infer column types of the file provided.");
}
return typeInferenceResult;
}
}
}
View on GitHub (pinned to 7b76e69cf9)
Solutions
- Verify the file has data rows beyond the header and values are readable text in a supported encoding (UTF-8)
- Inspect a few rows manually to confirm values match the expected delimiter and format
- Fix column contents that are entirely unparseable (e.g. all nulls, mixed binary)
- Run InferSplit first to confirm the file splits cleanly before type inference
- Sample-load the file with ML.NET's TextLoader manually to see per-column parse failures
Example fix
// before
var inference = ColumnInferenceApi.InferColumns("empty.csv", label: "y");
// after
// ensure the file contains rows with valid values, then:
var inference = ColumnInferenceApi.InferColumns("data-with-rows.csv", label: "y"); Defensive patterns
Strategy: validation
Validate before calling
var lineCount = File.ReadLines(path).Count();
if (lineCount <= 1) throw new InvalidDataException("File has no data rows"); Try / catch
try { var res = ColumnInferenceApi.InferColumns(path, label); }
catch (InferenceException ex) when (ex.Type == InferenceExceptionType.ColumnDataType)
{ /* check file content and encoding */ } Prevention
- Ensure data rows exist beyond the header
- Use UTF-8 encoding without corruption
- Confirm column values are parseable text before inference
When it happens
Trigger: Calling the AutoML column inference API on a file whose column values cannot be parsed into any supported type (all values null/garbage), a file with zero usable data rows, or a file that passed split but has empty/inconsistent fields.
Common situations: Empty or nearly empty CSVs (header only); columns full of malformed values (corrupted encodings, mixed binary/text); wrong delimiter causing each row to be a single untyped column; non-UTF8 encodings producing garbage tokens.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Unable to split the file provided into multiple, consistent
- can't add or update result that already save to csv
- IDatasetManager must be either ITrainTestDatasetManager or I
- OperationCanceledException
- Specified column {columnName} is not found in the dataset.
AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11).
Data as JSON: /api/errors/404ae0ca1dfc892f.
Report an issue: GitHub.