-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
ExperimentSettings.cs
96 lines (86 loc) · 4.02 KB
/
ExperimentSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.IO;
using System.Threading;
namespace Microsoft.ML.AutoML
{
/// <summary>
/// Base class for experiment settings. All task-specific AutoML experiment settings
/// (like <see cref="BinaryExperimentSettings"/>) inherit from this class.
/// </summary>
public abstract class ExperimentSettings
{
/// <summary>
/// Maximum time in seconds the experiment is allowed to run.
/// </summary>
/// <value>The default value is 86,400, the number of seconds in one day.</value>
/// <remarks>
/// An experiment may run for longer than <see name="MaxExperimentTimeInSeconds"/>.
/// This is because once AutoML starts training an ML.NET model, AutoML lets the
/// model train to completion. For instance, if the first model
/// AutoML trains takes 4 hours, and the second model trained takes 5 hours,
/// but <see name="MaxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
/// the experiment will run for 4 + 5 = 9 hours (not 6 hours).
/// </remarks>
public uint MaxExperimentTimeInSeconds { get; set; }
/// <summary>
/// Cancellation token for the AutoML experiment. It propagates the notification
/// that the experiment should be canceled.
/// </summary>
/// <remarks>
/// An experiment may not immediately stop after cancellation.
/// This is because once AutoML starts training an ML.NET model, AutoML lets the
/// model train to completion. For instance, if the first model
/// AutoML trains takes 4 hours, and the second model trained takes 5 hours,
/// but cancellation is requested after 6 hours,
/// the experiment will stop after 4 + 5 = 9 hours (not 6 hours).
/// </remarks>
public CancellationToken CancellationToken { get; set; }
/// <summary>
/// This is a pointer to a directory where all models trained during the AutoML experiment will be saved.
/// If <see langword="null"/>, models will be kept in memory instead of written to disk.
/// (Please note: for an experiment with high runtime operating on a large dataset, opting to keep models in
/// memory could cause a system to run out of memory.)
/// </summary>
/// <value>The default value is the directory named "Microsoft.ML.AutoML" in the current user's temporary folder.</value>
public DirectoryInfo CacheDirectory { get; set; }
/// <summary>
/// Whether AutoML should cache before ML.NET trainers.
/// See <see cref="TrainerInfo.WantCaching"/> for more information on caching.
/// </summary>
/// <value>The default value is <see cref="CacheBeforeTrainer.Auto"/>.</value>
public CacheBeforeTrainer CacheBeforeTrainer { get; set; }
internal int MaxModels;
/// <summary>
/// Initializes a new instance of <see cref="ExperimentSettings"/>.
/// </summary>
public ExperimentSettings()
{
MaxExperimentTimeInSeconds = 24 * 60 * 60;
CancellationToken = default;
CacheDirectory = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "Microsoft.ML.AutoML"));
CacheBeforeTrainer = CacheBeforeTrainer.Auto;
MaxModels = int.MaxValue;
}
}
/// <summary>
/// Whether AutoML should cache before ML.NET trainers.
/// See <see cref="TrainerInfo.WantCaching"/> for more information on caching.
/// </summary>
public enum CacheBeforeTrainer
{
/// <summary>
/// Dynamically determine whether to cache before each trainer.
/// </summary>
Auto,
/// <summary>
/// Always force caching on.
/// </summary>
On,
/// <summary>
/// Always force caching off.
/// </summary>
Off,
}
}