Beispiel #1
0
        private static void WriteSummary(NotebookMonitor monitor, TextWriter writer)
        {
            var summary = new List <IHtmlContent>();

            if (monitor.BestTrial != null)
            {
                var bestTrialParam = JsonSerializer.Serialize(monitor.BestTrial.TrialSettings.Parameter, new JsonSerializerOptions()
                {
                    WriteIndented = true,
                });
                summary.Add(h3("Best Trial"));
                summary.Add(p($"Id: {monitor.BestTrial.TrialSettings.TrialId}"));
                summary.Add(p($"Trainer: {monitor.BestTrial.TrialSettings.Pipeline}".Replace("Unknown=>", "")));
                summary.Add(p($"Parameters: {bestTrialParam}"));
            }
            if (monitor.ActiveTrial != null)
            {
                var activeTrialParam = JsonSerializer.Serialize(monitor.ActiveTrial.Parameter, new JsonSerializerOptions()
                {
                    WriteIndented = true,
                });

                summary.Add(h3("Active Trial"));
                summary.Add(p($"Id: {monitor.ActiveTrial.TrialId}"));
                summary.Add(p($"Trainer: {monitor.ActiveTrial.Pipeline}".Replace("Unknown=>", "")));
                summary.Add(p($"Parameters: {activeTrialParam}"));
            }

            writer.Write(div(summary));
        }
Beispiel #2
0
        private static void WriteTable(NotebookMonitor notebookMonitor, TextWriter writer)
        {
            var tableHeader = new List <IHtmlContent>();

            tableHeader.Add(h3("All Trials Table"));
            writer.Write(div(tableHeader));
            Formatter.GetPreferredFormatterFor(typeof(DataFrame), "text/html").Format(notebookMonitor.TrialData, writer);
        }
Beispiel #3
0
        private static void WriteChart(NotebookMonitor monitor, TextWriter writer)
        {
            var x = monitor.CompletedTrials.Select(x => x.TrialSettings.TrialId);
            var y = monitor.CompletedTrials.Select(x => x.Metric);

            var chart = Chart.Point <int, double, string>(x, y, "Plot Metrics over Trials.")
                        .WithTraceInfo(ShowLegend: false)
                        .WithXAxisStyle <double, double, string>(TitleText: "Trial", ShowGrid: false)
                        .WithYAxisStyle <double, double, string>(TitleText: "Metric", ShowGrid: false);

            var chartHeader = new List <IHtmlContent>();

            chartHeader.Add(h3("Plot Metrics over Trials"));
            writer.Write(div(chartHeader));


            Formatter.GetPreferredFormatterFor(typeof(Plotly.NET.GenericChart.GenericChart), "text/html").Format(chart, writer);

            // Works around issue with earlier versions of Plotly.NET - https://github.com/plotly/Plotly.NET/pull/305
            if (writer.ToString().EndsWith("</div    \r\n"))
            {
                writer.Write(">");
            }
        }