dotnet / machinelearning

ML.NET is an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
9.05k stars 1.88k forks source link

Schema mismatch for label column ': expected Boolean, got Single #7153

Closed robalexclark closed 1 month ago

robalexclark commented 6 months ago

I have an AutoML experiment as follows:

     List<QuoteModel> quoteModels = new List<QuoteModel>();

   //...get data from db and load into quoteModels

     MLContext mlContext = new MLContext();

     IDataView dataView = mlContext.Data.LoadFromEnumerable(quoteModels);
     TrainTestData splitDataView = mlContext.Data.TrainTestSplit(dataView, testFraction: 0.8);

     SweepablePipeline pipeline = mlContext.Auto().Featurizer(
         dataView)
         .Append(mlContext.Auto().BinaryClassification(labelColumnName: "LeadWon", featureColumnName: "PreviouslyFlooded"));

     AutoMLExperiment experiment = mlContext.Auto().CreateExperiment();

     experiment
         .SetPipeline(pipeline)
         .SetBinaryClassificationMetric(BinaryClassificationMetric.Accuracy, labelColumn: "LeadWon")
         .SetTrainingTimeInSeconds(60)
         .SetDataset(splitDataView);

     TrialResult experimentResults = await experiment.RunAsync();

The QuoteModel class is:


public class QuoteModel
{
    public string PreviouslyFlooded { get; set; }

    public Boolean LeadWon { get; set; }
}

When I run the experiment it gives the error:

System.ArgumentOutOfRangeException: 'Schema mismatch for label column 'LeadWon': expected Boolean, got Single

If you look at the QuoteModel class, the label column LeadWon is definately a boolean!!

Any ideas why/how it can give this seemingly impossible error?

dotnet-policy-service[bot] commented 2 months ago

This issue has been marked needs-author-action and may be missing some important information.

luisquintanilla commented 2 months ago

Hi @robalexclark,

Do you have a sample of what your dataset looks like?

dotnet-policy-service[bot] commented 2 months ago

This issue has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

dotnet-policy-service[bot] commented 1 month ago

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.