dotnet/machinelearning · error · ArgumentException

{DefaultColumnNames.Features} column must be of data type {N

Error message

{DefaultColumnNames.Features} column must be of data type {NumberDataViewType.Single}

What it means

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.

Source

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

        }

        private static void ValidateTrainData(IDataView trainData, ColumnInformation columnInformation)
        {
            if (trainData == null)
            {
                throw new ArgumentNullException(nameof(trainData), "Training data cannot be null");
            }

            if (DatasetDimensionsUtil.IsDataViewEmpty(trainData))
            {
                throw new ArgumentException("Training data has 0 rows", nameof(trainData));
            }

            foreach (var column in trainData.Schema)
            {
                if (column.Name == DefaultColumnNames.Features && column.Type.GetItemType() != NumberDataViewType.Single)
                {
                    throw new ArgumentException($"{DefaultColumnNames.Features} column must be of data type {NumberDataViewType.Single}", nameof(trainData));
                }

                if ((column.Name != columnInformation.LabelColumnName &&
                    column.Name != columnInformation.UserIdColumnName &&
                    column.Name != columnInformation.ItemIdColumnName &&
                    column.Name != columnInformation.GroupIdColumnName)
                    &&
                        column.Type.GetItemType() != BooleanDataViewType.Instance &&
                        column.Type.GetItemType() != NumberDataViewType.Single &&
                        column.Type.GetItemType() != TextDataViewType.Instance)
                {
                    throw new ArgumentException($"Only supported feature column types are " +
                        $"{BooleanDataViewType.Instance}, {NumberDataViewType.Single}, and {TextDataViewType.Instance}. " +
                        $"Please change the feature column {column.Name} of type {column.Type} to one of " +
                        $"the supported types.", nameof(trainData));
                }
            }
        }

View on GitHub (pinned to 7b76e69cf9)

Solutions

  1. Change the Features property/column to float[] (VectorType single) so item type is NumberDataViewType.Single
  2. Apply a ConvertTransform to cast the Features column to Single
  3. Rename the column if it is not an actual feature vector to avoid the "Features" name collision

Example fix

// before
public class ModelInput {
    [VectorType(10)] public double[] Features { get; set; }
}

// after
public class ModelInput {
    [VectorType(10)] public float[] Features { get; set; }
}
Defensive patterns

Strategy: validation

Validate before calling

var feat = trainData.Schema.GetColumnOrNull(DefaultColumnNames.Features);
if (feat.HasValue && feat.Value.Type.GetItemType() != NumberDataViewType.Single)
    throw new InvalidOperationException("Features column must be float (Single)");

Try / catch

try { var r = experiment.Execute(data, label, "A"); }
catch (ArgumentException ex) when (ex.Message.Contains("Features")) { /* apply ConvertTransform to Single and retry */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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