// todo: instead of internal methods, use static debug class w/ singleton logger?
        internal static RegressionResult AutoFit(this RegressionContext context,
                                                 IDataView trainData,
                                                 string label,
                                                 IDataView validationData            = null,
                                                 InferredColumn[] inferredColumns    = null,
                                                 AutoFitSettings settings            = null,
                                                 CancellationToken cancellationToken = default,
                                                 IProgress <RegressionIterationResult> iterationCallback = null,
                                                 IDebugLogger debugLogger = null)
        {
            // run autofit & get all pipelines run in that process
            var(allPipelines, bestPipeline) = AutoFitApi.Fit(trainData, validationData, label, inferredColumns,
                                                             settings, TaskKind.Regression, OptimizingMetric.RSquared, debugLogger);

            var results = new RegressionIterationResult[allPipelines.Length];

            for (var i = 0; i < results.Length; i++)
            {
                var iterationResult = allPipelines[i];
                var result          = new RegressionIterationResult(iterationResult.Model, (RegressionMetrics)iterationResult.EvaluatedMetrics, iterationResult.ScoredValidationData);
                results[i] = result;
            }
            var bestResult = new RegressionIterationResult(bestPipeline.Model, (RegressionMetrics)bestPipeline.EvaluatedMetrics, bestPipeline.ScoredValidationData);

            return(new RegressionResult(bestResult, results));
        }
 public RegressionResult(RegressionIterationResult bestPipeline,
                         RegressionIterationResult[] iterationResults)
 {
     BestPipeline     = bestPipeline;
     IterationResults = iterationResults;
 }