dotnet/machinelearning · error · ArgumentException

Provided {columnPurpose} column '{columnName}' not found in

Error message

Provided {columnPurpose} column '{columnName}' not found in training data. Did you mean '{closestNamed}'.

What it means

AutoML's ColumnInformation lets users designate label/group/weight/etc. columns by name. ValidateTrainDataColumn throws ArgumentException when the named column is absent from the training schema, appending a 'Did you mean' suggestion via edit-distance (ClosestNamed) when a close match exists.

Source

Thrown at src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs:260

        private static void ValidateTrainDataColumn(IDataView trainData, string columnName, string columnPurpose, IEnumerable<DataViewType> allowedTypes = null)
        {
            if (columnName == null)
            {
                return;
            }

            var nullableColumn = trainData.Schema.GetColumnOrNull(columnName);
            if (nullableColumn == null)
            {
                var closestNamed = ClosestNamed(trainData, columnName, 7);

                var exceptionMessage = $"Provided {columnPurpose} column '{columnName}' not found in training data.";
                if (closestNamed != string.Empty)
                {
                    exceptionMessage += $" Did you mean '{closestNamed}'.";
                }

                throw new ArgumentException(exceptionMessage);
            }

            if (allowedTypes == null)
            {
                return;
            }
            var column = nullableColumn.Value;
            var itemType = column.Type.GetItemType();
            if (!allowedTypes.Contains(itemType))
            {
                if (allowedTypes.Count() == 1)
                {
                    throw new ArgumentException($"Provided {columnPurpose} column '{columnName}' was of type {itemType}, " +
                        $"but only type {allowedTypes.First()} is allowed.");
                }
                else
                {
                    throw new ArgumentException($"Provided {columnPurpose} column '{columnName}' was of type {itemType}, " +

View on GitHub (pinned to 7b76e69cf9)

Solutions

  1. Match the column name exactly to one in trainData.Schema (verify with a quick schema dump).
  2. Use the 'Did you mean' suggestion in the message to correct the typo.
  3. Apply transforms that create the column before Execute, or reference the pre-transform source column.

Example fix

// before
var colInfo = new ColumnInformation { LabelColumnName = "PriceUSD" }; // actual: "price_usd"
// after
var actual = trainData.Schema.Select(c => c.Name).First(n => n.Equals("price_usd"));
var colInfo = new ColumnInformation { LabelColumnName = actual };
Defensive patterns

Strategy: validation

Validate before calling

bool exists = trainData.Schema.GetColumnOrNull(columnInfo.LabelColumnName) != null;
if (!exists) throw new ArgumentException($"label column '{columnInfo.LabelColumnName}' not in trainData");

Try / catch

try { result = experiment.Execute(trainData, settings, columnInfo); }
catch (ArgumentException ex) when (ex.Message.Contains("not found in training data")) { /* use the 'Did you mean' suggestion */ }

Prevention

When it happens

Trigger: Passing a ColumnInformation with a column name that doesn't exist in trainData, via Execute/ValidateColumnInformation or ValidateTrainDataColumns — typical typos, wrong casing, or names from a different dataset.

Common situations: Typo in column name; referring to a column that only exists after a transform not yet applied; copying ColumnInformation from another experiment on a different dataset.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11). Data as JSON: /api/errors/b5345c7add850e78. Report an issue: GitHub.