{"record":{"id":"b5345c7add850e78","repo":"dotnet/machinelearning","slug":"provided-columnpurpose-column-columnname-not","errorCode":null,"errorMessage":"Provided {columnPurpose} column '{columnName}' not found in training data. Did you mean '{closestNamed}'.","messagePattern":"Provided (.+?) column '(.+?)' not found in training data\\. Did you mean '(.+?)'\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs","lineNumber":260,"sourceCode":"        private static void ValidateTrainDataColumn(IDataView trainData, string columnName, string columnPurpose, IEnumerable<DataViewType> allowedTypes = null)\n        {\n            if (columnName == null)\n            {\n                return;\n            }\n\n            var nullableColumn = trainData.Schema.GetColumnOrNull(columnName);\n            if (nullableColumn == null)\n            {\n                var closestNamed = ClosestNamed(trainData, columnName, 7);\n\n                var exceptionMessage = $\"Provided {columnPurpose} column '{columnName}' not found in training data.\";\n                if (closestNamed != string.Empty)\n                {\n                    exceptionMessage += $\" Did you mean '{closestNamed}'.\";\n                }\n\n                throw new ArgumentException(exceptionMessage);\n            }\n\n            if (allowedTypes == null)\n            {\n                return;\n            }\n            var column = nullableColumn.Value;\n            var itemType = column.Type.GetItemType();\n            if (!allowedTypes.Contains(itemType))\n            {\n                if (allowedTypes.Count() == 1)\n                {\n                    throw new ArgumentException($\"Provided {columnPurpose} column '{columnName}' was of type {itemType}, \" +\n                        $\"but only type {allowedTypes.First()} is allowed.\");\n                }\n                else\n                {\n                    throw new ArgumentException($\"Provided {columnPurpose} column '{columnName}' was of type {itemType}, \" +","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs#L242-L278","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Match the column name exactly to one in trainData.Schema (verify with a quick schema dump).","Use the 'Did you mean' suggestion in the message to correct the typo.","Apply transforms that create the column before Execute, or reference the pre-transform source column."],"exampleFix":"// before\nvar colInfo = new ColumnInformation { LabelColumnName = \"PriceUSD\" }; // actual: \"price_usd\"\n// after\nvar actual = trainData.Schema.Select(c => c.Name).First(n => n.Equals(\"price_usd\"));\nvar colInfo = new ColumnInformation { LabelColumnName = actual };","handlingStrategy":"validation","validationCode":"bool exists = trainData.Schema.GetColumnOrNull(columnInfo.LabelColumnName) != null;\nif (!exists) throw new ArgumentException($\"label column '{columnInfo.LabelColumnName}' not in trainData\");","typeGuard":null,"tryCatchPattern":"try { result = experiment.Execute(trainData, settings, columnInfo); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"not found in training data\")) { /* use the 'Did you mean' suggestion */ }","preventionTips":["Copy column names from trainData.Schema, not from memory","Verify names after any transform that renames columns","Use InferColumnInformation for datasets you don't control"],"tags":["validation","column","automl"],"backgroundTag":"missing-required-argument","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}