{"record":{"id":"c41cd9d9ae349552","repo":"dotnet/machinelearning","slug":"defaultcolumnnames-features-column-must-be-of-da","errorCode":null,"errorMessage":"{DefaultColumnNames.Features} column must be of data type {NumberDataViewType.Single}","messagePattern":"(.+?) column must be of data type (.+?)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs","lineNumber":85,"sourceCode":"        }\n\n        private static void ValidateTrainData(IDataView trainData, ColumnInformation columnInformation)\n        {\n            if (trainData == null)\n            {\n                throw new ArgumentNullException(nameof(trainData), \"Training data cannot be null\");\n            }\n\n            if (DatasetDimensionsUtil.IsDataViewEmpty(trainData))\n            {\n                throw new ArgumentException(\"Training data has 0 rows\", nameof(trainData));\n            }\n\n            foreach (var column in trainData.Schema)\n            {\n                if (column.Name == DefaultColumnNames.Features && column.Type.GetItemType() != NumberDataViewType.Single)\n                {\n                    throw new ArgumentException($\"{DefaultColumnNames.Features} column must be of data type {NumberDataViewType.Single}\", nameof(trainData));\n                }\n\n                if ((column.Name != columnInformation.LabelColumnName &&\n                    column.Name != columnInformation.UserIdColumnName &&\n                    column.Name != columnInformation.ItemIdColumnName &&\n                    column.Name != columnInformation.GroupIdColumnName)\n                    &&\n                        column.Type.GetItemType() != BooleanDataViewType.Instance &&\n                        column.Type.GetItemType() != NumberDataViewType.Single &&\n                        column.Type.GetItemType() != TextDataViewType.Instance)\n                {\n                    throw new ArgumentException($\"Only supported feature column types are \" +\n                        $\"{BooleanDataViewType.Instance}, {NumberDataViewType.Single}, and {TextDataViewType.Instance}. \" +\n                        $\"Please change the feature column {column.Name} of type {column.Type} to one of \" +\n                        $\"the supported types.\", nameof(trainData));\n                }\n            }\n        }","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs#L67-L103","documentation":"Thrown when a column named \"Features\" in the training data schema exists but its item type is not NumberDataViewType.Single (float). ML.NET AutoML expects the default Features column to be a vector of Single values; any other element type (double, vector-of-vector, key, text) is rejected.","triggerScenarios":"Loading data where a schema column is literally named \"Features\" with item type other than float — e.g. a double[] feature array, or a text column accidentally named Features.","commonSituations":"Defining a C# class with double[] Features and loading it via LoadFromEnumerable; schema from a previous pipeline version using double features; a string column named \"Features\" from a CSV header.","solutions":["Change the Features property/column to float[] (VectorType single) so item type is NumberDataViewType.Single","Apply a ConvertTransform to cast the Features column to Single","Rename the column if it is not an actual feature vector to avoid the \"Features\" name collision"],"exampleFix":"// before\npublic class ModelInput {\n    [VectorType(10)] public double[] Features { get; set; }\n}\n\n// after\npublic class ModelInput {\n    [VectorType(10)] public float[] Features { get; set; }\n}","handlingStrategy":"validation","validationCode":"var feat = trainData.Schema.GetColumnOrNull(DefaultColumnNames.Features);\nif (feat.HasValue && feat.Value.Type.GetItemType() != NumberDataViewType.Single)\n    throw new InvalidOperationException(\"Features column must be float (Single)\");","typeGuard":null,"tryCatchPattern":"try { var r = experiment.Execute(data, label, \"A\"); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Features\")) { /* apply ConvertTransform to Single and retry */ }","preventionTips":["Declare Features as float[] with [VectorType(n)] in ModelInput classes","Avoid naming non-feature columns \"Features\"","Insert a ConvertTransform (double→single) when data comes from double-precision sources"],"tags":["dotnet","mlnet","automl","schema","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}