Ejemplo n.º 1
0
 public AutoFitter(MLContext mlContext, OptimizingMetricInfo metricInfo, AutoFitSettings settings,
                   TaskKind task, string label, PurposeInference.Column[] puproseOverrides,
                   IDataView trainData, IDataView validationData, IDebugLogger debugLogger)
 {
     _debugLogger          = debugLogger;
     _history              = new List <PipelineRunResult>();
     _label                = label;
     _mlContext            = mlContext;
     _optimizingMetricInfo = metricInfo;
     _settings             = settings ?? new AutoFitSettings();
     _puproseOverrides     = puproseOverrides;
     _trainData            = trainData;
     _task           = task;
     _validationData = validationData;
 }
Ejemplo n.º 2
0
        public static (PipelineRunResult[] allPipelines, PipelineRunResult bestPipeline) Fit(IDataView trainData,
                                                                                             IDataView validationData, string label, InferredColumn[] inferredColumns, AutoFitSettings settings,
                                                                                             TaskKind task, OptimizingMetric metric, IDebugLogger debugLogger)
        {
            // hack: init new MLContext
            var mlContext = new MLContext();

            // infer pipelines
            var optimizingMetricfInfo = new OptimizingMetricInfo(metric);
            var autoFitter            = new AutoFitter(mlContext, optimizingMetricfInfo, settings, task,
                                                       label, ToInternalColumnPurposes(inferredColumns),
                                                       trainData, validationData, debugLogger);
            var allPipelines = autoFitter.Fit(1);

            var bestScore    = allPipelines.Max(p => p.Score);
            var bestPipeline = allPipelines.First(p => p.Score == bestScore);

            return(allPipelines, bestPipeline);
        }