2

I'm evaluating ML.NET Model Builder (Preview) 16.1.0.2027905. When I go to train, the Builder lets me specify "Time to train (seconds)" (See Picture):

enter image description here

However, when I get to Step#6 and generate the code, I can't seem to find where the "Time to train" is specified...

The ML.NET Builder creates this function for me automatically in the ModelBuilder.cs file:

    public static ITransformer TrainModel(MLContext mlContext, IDataView trainingDataView, IEstimator<ITransformer> trainingPipeline)
    {
        Console.WriteLine("=============== Training  model ===============");

        ITransformer model = trainingPipeline.Fit(trainingDataView);

        Console.WriteLine("=============== End of training process ===============");
        return model;
    }

but I looked in the debugger at the mlContext, trainingDataView, trainingPipeline objects and didn't immediately see where I can specify time to train. Also, I did a global text search for 3600 (which is the time I trained for) and I didn't find any interesting code that way.

Is there some easy way in ML.NET to specify "Time to train" in seconds?

I'm asking this question because I want to call ModelBuilder.TrainModel manually with a user specified training interval. I don't want to always be required to use the ML.NET Builder GUI to retrain my model.

Shawn Eary
  • 684
  • 2
  • 7
  • 21

1 Answers1

5

The Model Builder uses AutoML behind the scenes. The code that it produces is the pure ML.NET API code so it wouldn't have a way to specify the training time.

If you want to use that, you would need to use the AutoML API. With that it has a way to specify the training time. Here's the doc that shows it, but it would be something like the below code:

var settings = new RegressionExperimentSettings
{
    MaxExperimentTimeInSeconds = 20,
};

Here's a full sample on it which was used in this video.

Hope that helps!

Jon
  • 2,644
  • 1
  • 22
  • 31
  • The C# AutoML API works for me but for some reason when I call CreateMulticlassClassificationExperiment with a maxExperimentTimeInSeconds greater than 12 seconds (or so), the experiment takes an inordinate amount of time to finish. For example: if I specify 10 seconds, it takes 10 seconds to finish, but if I specify 15 seconds, it might take 6 minutes to finish. I tried two different computers and I haven't figured out why the maxExperimentTimeInSeconds parameter doesn't seem to be working for me. Maybe a new question but I don't want to go that far just yet. – Shawn Eary Jun 23 '20 at 22:07