Exemple #1
0
        public void CreateSweepableEstimatorPipelineFromSweepableEstimatorTest()
        {
            var estimator = SweepableEstimatorFactory.CreateFastForestBinary(new FastForestOption());
            var pipeline  = estimator.Append(estimator);

            pipeline.ToString().Should().Be("FastForestBinary=>FastForestBinary");
        }
Exemple #2
0
        public void CreateSweepableEstimatorPipelineFromSweepableEstimatorAndIEstimatorTest()
        {
            var context   = new MLContext();
            var estimator = SweepableEstimatorFactory.CreateFastForestBinary(new FastForestOption());
            var pipeline  = estimator.Append(context.Transforms.Concatenate("output", "input"));

            pipeline.ToString().Should().Be("FastForestBinary=>Unknown");
        }
Exemple #3
0
        public void CreateMultiModelPipelineFromSweepableEstimatorAndMultiClassifiers()
        {
            var context  = new MLContext();
            var pipeline = SweepableEstimatorFactory.CreateFastForestBinary(new FastForestOption())
                           .Append(context.Auto().MultiClassification());

            var json = JsonSerializer.Serialize(pipeline, this._jsonSerializerOptions);

            Approvals.Verify(json);
        }
Exemple #4
0
        public void AppendIEstimatorToSweepabeEstimatorPipelineTest()
        {
            var context   = new MLContext();
            var estimator = context.Transforms.Concatenate("output", "input");
            var pipeline  = estimator.Append(SweepableEstimatorFactory.CreateFastForestBinary(new FastForestOption()));

            pipeline = pipeline.Append(context.Transforms.CopyColumns("output", "input"));

            pipeline.ToString().Should().Be("Unknown=>FastForestBinary=>Unknown");
        }
        /// <summary>
        /// Create a list of <see cref="SweepableEstimator"/> for binary classification.
        /// </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[] BinaryClassification(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.CreateFastTreeBinary(fastTreeOption, fastTreeSearchSpace ?? new SearchSpace <FastTreeOption>(fastTreeOption)));
            }

            if (useFastForest)
            {
                fastForestOption = fastForestOption ?? new FastForestOption();
                fastForestOption.LabelColumnName         = labelColumnName;
                fastForestOption.FeatureColumnName       = featureColumnName;
                fastForestOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateFastForestBinary(fastForestOption, fastForestSearchSpace ?? new SearchSpace <FastForestOption>(fastForestOption)));
            }

            if (useLgbm)
            {
                lgbmOption = lgbmOption ?? new LgbmOption();
                lgbmOption.LabelColumnName         = labelColumnName;
                lgbmOption.FeatureColumnName       = featureColumnName;
                lgbmOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateLightGbmBinary(lgbmOption, lgbmSearchSpace ?? new SearchSpace <LgbmOption>(lgbmOption)));
            }

            if (useLbfgs)
            {
                lbfgsOption = lbfgsOption ?? new LbfgsOption();
                lbfgsOption.LabelColumnName         = labelColumnName;
                lbfgsOption.FeatureColumnName       = featureColumnName;
                lbfgsOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateLbfgsLogisticRegressionBinary(lbfgsOption, lbfgsSearchSpace ?? new SearchSpace <LbfgsOption>(lbfgsOption)));
            }

            if (useSdca)
            {
                sdcaOption = sdcaOption ?? new SdcaOption();
                sdcaOption.LabelColumnName         = labelColumnName;
                sdcaOption.FeatureColumnName       = featureColumnName;
                sdcaOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateSdcaLogisticRegressionBinary(sdcaOption, sdcaSearchSpace ?? new SearchSpace <SdcaOption>(sdcaOption)));
            }

            return(res.ToArray());
        }