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)); }
/// <summary> /// Create a list of <see cref="SweepableEstimator"/> for regression. /// </summary> /// <param name="labelColumnName">label column name.</param> /// <param name="featureColumnName">feature column name.</param> /// <param name="exampleWeightColumnName">example weight column name.</param> /// <param name="useFastForest">true if use fast forest as available trainer.</param> /// <param name="useLgbm">true if use lgbm as available trainer.</param> /// <param name="useFastTree">true if use fast tree as available trainer.</param> /// <param name="useLbfgs">true if use lbfgs as available trainer.</param> /// <param name="useSdca">true if use sdca as available trainer.</param> /// <param name="fastTreeOption">if provided, use it as initial option for fast tree, otherwise the default option will be used.</param> /// <param name="lgbmOption">if provided, use it as initial option for lgbm, otherwise the default option will be used.</param> /// <param name="fastForestOption">if provided, use it as initial option for fast forest, otherwise the default option will be used.</param> /// <param name="lbfgsOption">if provided, use it as initial option for lbfgs, otherwise the default option will be used.</param> /// <param name="sdcaOption">if provided, use it as initial option for sdca, otherwise the default option will be used.</param> /// <param name="fastTreeSearchSpace">if provided, use it as search space for fast tree, otherwise the default search space will be used.</param> /// <param name="lgbmSearchSpace">if provided, use it as search space for lgbm, otherwise the default search space will be used.</param> /// <param name="fastForestSearchSpace">if provided, use it as search space for fast forest, otherwise the default search space will be used.</param> /// <param name="lbfgsSearchSpace">if provided, use it as search space for lbfgs, otherwise the default search space will be used.</param> /// <param name="sdcaSearchSpace">if provided, use it as search space for sdca, otherwise the default search space will be used.</param> /// <returns></returns> public SweepableEstimator[] Regression(string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, bool useFastForest = true, bool useLgbm = true, bool useFastTree = true, bool useLbfgs = true, bool useSdca = true, FastTreeOption fastTreeOption = null, LgbmOption lgbmOption = null, FastForestOption fastForestOption = null, LbfgsOption lbfgsOption = null, SdcaOption sdcaOption = null, SearchSpace <FastTreeOption> fastTreeSearchSpace = null, SearchSpace <LgbmOption> lgbmSearchSpace = null, SearchSpace <FastForestOption> fastForestSearchSpace = null, SearchSpace <LbfgsOption> lbfgsSearchSpace = null, SearchSpace <SdcaOption> sdcaSearchSpace = null) { var res = new List <SweepableEstimator>(); if (useFastTree) { fastTreeOption = fastTreeOption ?? new FastTreeOption(); fastTreeOption.LabelColumnName = labelColumnName; fastTreeOption.FeatureColumnName = featureColumnName; fastTreeOption.ExampleWeightColumnName = exampleWeightColumnName; res.Add(SweepableEstimatorFactory.CreateFastTreeRegression(fastTreeOption, fastTreeSearchSpace ?? new SearchSpace <FastTreeOption>(fastTreeOption))); } if (useFastForest) { fastForestOption = fastForestOption ?? new FastForestOption(); fastForestOption.LabelColumnName = labelColumnName; fastForestOption.FeatureColumnName = featureColumnName; fastForestOption.ExampleWeightColumnName = exampleWeightColumnName; res.Add(SweepableEstimatorFactory.CreateFastForestRegression(fastForestOption, fastForestSearchSpace ?? new SearchSpace <FastForestOption>(fastForestOption))); } if (useLgbm) { lgbmOption = lgbmOption ?? new LgbmOption(); lgbmOption.LabelColumnName = labelColumnName; lgbmOption.FeatureColumnName = featureColumnName; lgbmOption.ExampleWeightColumnName = exampleWeightColumnName; res.Add(SweepableEstimatorFactory.CreateLightGbmRegression(lgbmOption, lgbmSearchSpace ?? new SearchSpace <LgbmOption>(lgbmOption))); } if (useLbfgs) { lbfgsOption = lbfgsOption ?? new LbfgsOption(); lbfgsOption.LabelColumnName = labelColumnName; lbfgsOption.FeatureColumnName = featureColumnName; lbfgsOption.ExampleWeightColumnName = exampleWeightColumnName; res.Add(SweepableEstimatorFactory.CreateLbfgsPoissonRegressionRegression(lbfgsOption, lbfgsSearchSpace ?? new SearchSpace <LbfgsOption>(lbfgsOption))); } if (useSdca) { sdcaOption = sdcaOption ?? new SdcaOption(); sdcaOption.LabelColumnName = labelColumnName; sdcaOption.FeatureColumnName = featureColumnName; sdcaOption.ExampleWeightColumnName = exampleWeightColumnName; res.Add(SweepableEstimatorFactory.CreateSdcaRegression(sdcaOption, sdcaSearchSpace ?? new SearchSpace <SdcaOption>(sdcaOption))); } return(res.ToArray()); }
public override IEstimator <ITransformer> BuildFromOption(MLContext context, LgbmOption param) { var option = new LightGbmRegressionTrainer.Options() { NumberOfLeaves = param.NumberOfLeaves, NumberOfIterations = param.NumberOfTrees, MinimumExampleCountPerLeaf = param.MinimumExampleCountPerLeaf, LearningRate = param.LearningRate, NumberOfThreads = AutoMlUtils.GetNumberOfThreadFromEnvrionment(), LabelColumnName = param.LabelColumnName, FeatureColumnName = param.FeatureColumnName, ExampleWeightColumnName = param.ExampleWeightColumnName, Booster = new GradientBooster.Options() { SubsampleFraction = param.SubsampleFraction, FeatureFraction = param.FeatureFraction, L1Regularization = param.L1Regularization, L2Regularization = param.L2Regularization, }, MaximumBinCountPerFeature = param.MaximumBinCountPerFeature, }; return(context.Regression.Trainers.LightGbm(option)); }
internal SweepableEstimator[] MultiClassification(string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, bool useFastForest = true, bool useLgbm = true, bool useFastTree = true, bool useLbfgs = true, bool useSdca = true, FastTreeOption fastTreeOption = null, LgbmOption lgbmOption = null, FastForestOption fastForestOption = null, LbfgsOption lbfgsOption = null, SdcaOption sdcaOption = null, SearchSpace <FastTreeOption> fastTreeSearchSpace = null, SearchSpace <LgbmOption> lgbmSearchSpace = null, SearchSpace <FastForestOption> fastForestSearchSpace = null, SearchSpace <LbfgsOption> lbfgsSearchSpace = null, SearchSpace <SdcaOption> sdcaSearchSpace = null) { var res = new List <SweepableEstimator>(); if (useFastTree) { fastTreeOption = fastTreeOption ?? new FastTreeOption(); fastTreeOption.LabelColumnName = labelColumnName; fastTreeOption.FeatureColumnName = featureColumnName; fastTreeOption.ExampleWeightColumnName = exampleWeightColumnName; res.Add(SweepableEstimatorFactory.CreateFastTreeOva(fastTreeOption, fastTreeSearchSpace ?? new SearchSpace <FastTreeOption>())); } if (useFastForest) { fastForestOption = fastForestOption ?? new FastForestOption(); fastForestOption.LabelColumnName = labelColumnName; fastForestOption.FeatureColumnName = featureColumnName; fastForestOption.ExampleWeightColumnName = exampleWeightColumnName; res.Add(SweepableEstimatorFactory.CreateFastForestOva(fastForestOption, fastForestSearchSpace ?? new SearchSpace <FastForestOption>())); } if (useLgbm) { lgbmOption = lgbmOption ?? new LgbmOption(); lgbmOption.LabelColumnName = labelColumnName; lgbmOption.FeatureColumnName = featureColumnName; lgbmOption.ExampleWeightColumnName = exampleWeightColumnName; res.Add(SweepableEstimatorFactory.CreateLightGbmMulti(lgbmOption, lgbmSearchSpace ?? new SearchSpace <LgbmOption>())); } if (useLbfgs) { lbfgsOption = lbfgsOption ?? new LbfgsOption(); lbfgsOption.LabelColumnName = labelColumnName; lbfgsOption.FeatureColumnName = featureColumnName; lbfgsOption.ExampleWeightColumnName = exampleWeightColumnName; res.Add(SweepableEstimatorFactory.CreateLbfgsLogisticRegressionOva(lbfgsOption, lbfgsSearchSpace ?? new SearchSpace <LbfgsOption>())); res.Add(SweepableEstimatorFactory.CreateLbfgsMaximumEntropyMulti(lbfgsOption, lbfgsSearchSpace ?? new SearchSpace <LbfgsOption>())); } if (useSdca) { sdcaOption = sdcaOption ?? new SdcaOption(); sdcaOption.LabelColumnName = labelColumnName; sdcaOption.FeatureColumnName = featureColumnName; sdcaOption.ExampleWeightColumnName = exampleWeightColumnName; res.Add(SweepableEstimatorFactory.CreateSdcaMaximumEntropyMulti(sdcaOption, sdcaSearchSpace ?? new SearchSpace <SdcaOption>())); res.Add(SweepableEstimatorFactory.CreateSdcaLogisticRegressionOva(sdcaOption, sdcaSearchSpace ?? new SearchSpace <SdcaOption>())); } return(res.ToArray()); }