public void SweepablePipeline_Append_SweepableEstimator_Test() { var pipeline = new SweepablePipeline(); var concatOption = new ConcatOption() { InputColumnNames = new List <string> { "a", "b", "c" }.ToArray(), OutputColumnName = "a", }; var lgbmOption = new LgbmOption() { FeatureColumnName = "Feature", LabelColumnName = "Label", }; // pipeline can append a single sweepable estimator pipeline = pipeline.Append(SweepableEstimatorFactory.CreateConcatenate(concatOption)); // pipeline can append muliple sweepable estimators. pipeline = pipeline.Append(SweepableEstimatorFactory.CreateLightGbmBinary(lgbmOption), SweepableEstimatorFactory.CreateConcatenate(concatOption)); // pipeline can append sweepable pipelines mixed with sweepble estimators pipeline = pipeline.Append(SweepableEstimatorFactory.CreateConcatenate(concatOption), pipeline); // pipeline can append sweepable pipelines. pipeline = pipeline.Append(pipeline, pipeline); Approvals.Verify(JsonSerializer.Serialize(pipeline, _jsonSerializerOptions)); }
public static SweepablePipeline ToPipeline(this SweepablePipelineDataContract pipelineContract, MLContext context) { var sweepablePipeline = new SweepablePipeline(); foreach (var node in pipelineContract.Estimators) { sweepablePipeline.Append(node.Select(n => context.AutoML().Serializable().Factory.CreateSweepableEstimator(n)).ToArray()); } return(sweepablePipeline); }
public SweepablePipeline BuildPipeline(MLContext context, IEnumerable <Column> columns) { var sweepablePipeline = new SweepablePipeline(); foreach (var column in columns) { switch (column.ColumnPurpose) { case ColumnPurpose.NumericFeature: sweepablePipeline.Append(this.GetSuggestedNumericColumnTransformers(context, column).ToArray()); break; case ColumnPurpose.CategoricalFeature: sweepablePipeline.Append(this.GetSuggestedCatagoricalColumnTransformers(context, column).ToArray()); break; case ColumnPurpose.TextFeature: sweepablePipeline.Append(this.GetSuggestedTextColumnTransformers(context, column).ToArray()); break; case ColumnPurpose.Label: sweepablePipeline.Append(this.GetSuggestedLabelColumnTransformers(context, column).ToArray()); break; default: break; } } var featureColumns = columns.Where(c => c.ColumnPurpose == ColumnPurpose.CategoricalFeature || c.ColumnPurpose == ColumnPurpose.NumericFeature || c.ColumnPurpose == ColumnPurpose.TextFeature) .Select(c => c.Name) .ToArray(); if (this.PipelineBuilderOption.IsUsingSingleFeatureTrainer) { sweepablePipeline.Append(context.AutoML().Serializable().Transformer.Concatnate(featureColumns, "_FEATURE")); var labelColumn = columns.Where(c => c.ColumnPurpose == ColumnPurpose.Label).First(); sweepablePipeline.Append(this.GetSuggestedSingleFeatureTrainers(context, labelColumn, "_FEATURE").ToArray()); } return(sweepablePipeline); }