Where to Specify Time to Train in ML.NET

孤街浪徒 提交于 2021-01-06 05:42:06

问题


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):

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.


回答1:


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!



来源:https://stackoverflow.com/questions/62440229/where-to-specify-time-to-train-in-ml-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!