Skip to content

One or more errors occurred. (Schema mismatch for score column 'Score': expected vector of two or more items of type Single, got Vector<Single, 1> Arg_ParamName_Name) #6573

Description

@rzechu

System Information (please complete the following information):

  • OS & Version: Windows 11
  • ML.NET Version: ML.NET v0.20.0
  • .NET Version: NET 6.0

Describe the bug
One or more errors occurred. (Schema mismatch for score column 'Score': expected vector of two or more items of type Single, got Vector<Single, 1> Arg_ParamName_Name)
on AutoML Multiclasstraining

SELECT  
CAST(DecimalColumn1 as real) as [DecimalColumn1], 
CAST(IntColumn2 as real) as [IntColumn2], 
CAST(IntColumn3 as real) as [IntColumn3], 
CAST(IntColumn4 as real) as [IntColumn4], 
cast([LongStringColumn1] as varchar(2000)) as [LongStringColumn1],  /*nvarchar(max) */
[Name], /*nvarchar(128) */
[ShortStringColumn3] as [ShortStringColumn3], /*nvarchar(128) */
cast([LongStringColumn3] as varchar(2000)) as [LabelColumn]  /*nvarchar(max) */
FROM Documents 

image

To Reproduce
Steps to reproduce the behavior:

  1. MulticlassClassification
  2. Loading data from MSSQL Database
var loader = MLContext.Data.CreateDatabaseLoader(columns.ToArray());
var dbSource = new DatabaseSource(SqlClientFactory.Instance, connectionString, sqlQuery);
var iDataView = loader.Load(dbSource);
columns
    [0]: "Name=DecimalColumn1      Type=Single"
    [1]: "Name=IntColumn2               Type=Single"
    [2]: "Name=IntColumn3               Type=Single"
    [3]: "Name=IntColumn4               Type=Single"
    [4]: "Name=LongStringColumn1  Type=String"
    [5]: "Name=Name                        Type=String"
    [6]: "Name=ShortStringColumn3 Type=String"
    [7]: "Name=LabelColumn             Type=String"
iDataView
    [0]: "Index=0 Name=DecimalColumn1     Type=Single IsHidden=False"
    [1]: "Index=1 Name=IntColumn2               Type=Single IsHidden=False"
    [2]: "Index=2 Name=IntColumn3               Type=Single IsHidden=False"
    [3]: "Index=3 Name=IntColumn4               Type=Single IsHidden=False"
    [4]: "Index=4 Name=LongStringColumn1  Type=String IsHidden=False"
    [5]: "Index=5 Name=Name                         Type=String IsHidden=False"
    [6]: "Index=6 Name=ShortStringColumn3 Type=String IsHidden=False"
    [7]: "Index=7 Name=LabelColumn             Type=String IsHidden=False"

iDataView.Preview()
image

image

var experiment = MLContext.Auto().CreateMulticlassClassificationExperiment(multiClassExperimentSettings);
var experimentResult = experiment.Execute(trainData: iDataView, labelColumnName: runExperimentDto.LabelColumnName, progressHandler: progressHandler);

Error:

Schema mismatch for score column 'Score': expected vector of two or more items of type Single, got Vector<Single, 1> (Parameter 'schema')
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Microsoft.ML.AutoML.AutoMLExperiment.Run()
   at Microsoft.ML.AutoML.MulticlassClassificationExperiment.Execute(IDataView trainData, ColumnInformation columnInformation, IEstimator`1 preFeaturizer, IProgress`1 progressHandler)
   at AI.AutoML.Trainers.MulticlassClassification.RunExperiment(IDataView trainingDataView, RunExperimentDto runExperimentDto) in C:\.....\_myapp.cs:line 63

InnerException

Schema mismatch for score column 'Score': expected vector of two or more items of type Single, got Vector<Single, 1> (Parameter 'schema')

   at Microsoft.ML.Data.MulticlassClassificationEvaluator.CheckScoreAndLabelTypes(RoleMappedSchema schema)
   at Microsoft.ML.Data.EvaluatorBase`1.CheckColumnTypes(RoleMappedSchema schema)
   at Microsoft.ML.Data.EvaluatorBase`1.Microsoft.ML.Data.IEvaluator.Evaluate(RoleMappedData data)
   at Microsoft.ML.Data.MulticlassClassificationEvaluator.Evaluate(IDataView data, String label, String score, String predictedLabel)
   at Microsoft.ML.MulticlassClassificationCatalog.<>c__DisplayClass6_0.<CrossValidate>b__0(CrossValidationResult x)
   at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
   at Microsoft.ML.AutoML.MulticlassClassificationRunner.Run(TrialSettings settings)
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Microsoft.ML.AutoML.AutoMLExperiment.<RunAsync>d__26.MoveNext()

image

Expected behavior
This case should work (I am using same scenario for many other columns and only few cases gives this error - propably related to nvarchar(max) columns or some kind of mix columns
I am many times using 2 varchars + 2 ints as source with int/varchar output and work without any doubts
Or should be understandable workaround

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Doc bugs, questions, minor issues, etc.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions