-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExperimentMonitor.cs
42 lines (36 loc) · 1.31 KB
/
ExperimentMonitor.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
using Microsoft.ML.AutoML;
public class ExperimentMonitor : IMonitor
{
private readonly SweepablePipeline _pipeline;
private readonly List<TrialResult> _completedTrials;
public ExperimentMonitor(SweepablePipeline pipeline)
{
_pipeline = pipeline;
_completedTrials = new List<TrialResult>();
}
public IEnumerable<TrialResult> GetCompletedTrials() => _completedTrials;
public void ReportBestTrial(TrialResult result)
{
return;
}
public void ReportCompletedTrial(TrialResult result)
{
var trialId = result.TrialSettings.TrialId;
var timeToTrain = result.DurationInMilliseconds;
var pipeline = _pipeline.ToString(result.TrialSettings.Parameter);
_completedTrials.Add(result);
Console.WriteLine($"Trial {trialId} finished training in {timeToTrain}ms with pipeline {pipeline}");
}
public void ReportFailTrial(TrialSettings settings, Exception exception = null)
{
if (exception.Message.Contains("Operation was canceled."))
{
Console.WriteLine($"{settings.TrialId} cancelled. Time budget exceeded.");
}
Console.WriteLine($"{settings.TrialId} failed with exception {exception.Message}");
}
public void ReportRunningTrial(TrialSettings setting)
{
return;
}
}