dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.16k stars 5.83k forks source link

AutoML Experiment example fails #39298

Open gewarren opened 5 months ago

gewarren commented 5 months ago

Issue moved from MicrosoftDocs/feedback#3979


From @Elantonio on Monday, January 22, 2024 1:15:45 PM

I'm following the example code on: https://learn.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/how-to-use-the-automl-api

MyMLContext = new MLContext();
ColumnInferenceResults columnInference =
  MyMLContext.Auto().InferColumns(TrainFilePath, labelColumnName: LabelColumnName, groupColumns: false);

TextLoader loader = MyMLContext.Data.CreateTextLoader(columnInference.TextLoaderOptions);

// Load data into IDataView
IDataView data = loader.Load(TrainFilePath);

TrainTestData trainValidationData = MyMLContext.Data.TrainTestSplit(data, testFraction: 0.2);

SweepablePipeline pipeline =
  MyMLContext.Auto().Featurizer(data, columnInformation: columnInference.ColumnInformation)
      .Append(MyMLContext.Auto().Regression(labelColumnName: columnInference.ColumnInformation.LabelColumnName));

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

experiment
  .SetPipeline(pipeline)
  .SetRegressionMetric(RegressionMetric.RSquared, labelColumn: columnInference.ColumnInformation.LabelColumnName)
  .SetTrainingTimeInSeconds((uint)Math.Max(seconds, 10))
  .SetDataset(trainValidationData);

TrialResult experimentResults = experiment.Run();

But it gives an error on experiment.Run(); Error = "One or more errors occurred. (Could not find feature column 'Features' (Parameter 'inputSchema')"

I can't seem to find what I'm missing here. Anyone an idea, and if so should the docu be updated?

To reproduce Steps to reproduce the behavior:

-in vs2022 create a project -Add nuget Microsoft.ML.AutoML 0.21.1 -create a class Predictor -add an instantiator with the above code; -Build -Instantiate the class

Expected behavior Run without error

Environment Desktop OS: Win11 . Visual Studio Community 2022 (64-bit) -17.6.4


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

gewarren commented 5 months ago

Issue moved from MicrosoftDocs/feedback#3979


From @welcome[bot] on Monday, January 22, 2024 1:15:48 PM

Thank you for opening an issue! One of our team members will get back to you with additional information.

If this is a product issue, please close this issue and contact the product's support instead. For a list of support websites, see Support for Microsoft products and apps.