Ejemplo n.º 1
0
        public static CommonOutputs.AnomalyDetectionOutput CreateAnomalyPipelineEnsemble(IHostEnvironment env, PipelineAnomalyInput input)
        {
            Contracts.CheckValue(env, nameof(env));
            var host = env.Register("CombineModels");

            host.CheckValue(input, nameof(input));
            host.CheckNonEmpty(input.Models, nameof(input.Models));

            IRegressionOutputCombiner combiner;

            switch (input.ModelCombiner)
            {
            case ScoreCombiner.Median:
                combiner = new Median(host);
                break;

            case ScoreCombiner.Average:
                combiner = new Average(host);
                break;

            default:
                throw host.Except("Unknown combiner kind");
            }
            var ensemble = SchemaBindablePipelineEnsembleBase.Create(host, input.Models, combiner, AnnotationUtils.Const.ScoreColumnKind.AnomalyDetection);

            return(CreatePipelineEnsemble <CommonOutputs.AnomalyDetectionOutput>(host, input.Models, ensemble));
        }
Ejemplo n.º 2
0
        public static CommonOutputs.BinaryClassificationOutput CreateBinaryPipelineEnsemble(IHostEnvironment env, PipelineClassifierInput input)
        {
            Contracts.CheckValue(env, nameof(env));
            var host = env.Register("CombineModels");

            host.CheckValue(input, nameof(input));
            host.CheckNonEmpty(input.Models, nameof(input.Models));

            IBinaryOutputCombiner combiner;

            switch (input.ModelCombiner)
            {
            case ClassifierCombiner.Median:
                combiner = new Median(host);
                break;

            case ClassifierCombiner.Average:
                combiner = new Average(host);
                break;

            case ClassifierCombiner.Vote:
                combiner = new Voting(host);
                break;

            default:
                throw host.Except("Unknown combiner kind");
            }
            var ensemble = SchemaBindablePipelineEnsembleBase.Create(host, input.Models, combiner, MetadataUtils.Const.ScoreColumnKind.BinaryClassification);

            return(CreatePipelineEnsemble <CommonOutputs.BinaryClassificationOutput>(host, input.Models, ensemble));
        }
Ejemplo n.º 3
0
        public static CommonOutputs.MulticlassClassificationOutput CreateMulticlassPipelineEnsemble(IHostEnvironment env, PipelineClassifierInput input)
        {
            Contracts.CheckValue(env, nameof(env));
            var host = env.Register("CombineModels");

            host.CheckValue(input, nameof(input));
            host.CheckNonEmpty(input.Models, nameof(input.Models));

            IOutputCombiner <VBuffer <Single> > combiner;

            switch (input.ModelCombiner)
            {
            case ClassifierCombiner.Median:
                combiner = new MultiMedian(host, new MultiMedian.Options()
                {
                    Normalize = true
                });
                break;

            case ClassifierCombiner.Average:
                combiner = new MultiAverage(host, new MultiAverage.Options()
                {
                    Normalize = true
                });
                break;

            case ClassifierCombiner.Vote:
                combiner = new MultiVoting(host);
                break;

            default:
                throw host.Except("Unknown combiner kind");
            }
            var ensemble = SchemaBindablePipelineEnsembleBase.Create(host, input.Models, combiner, AnnotationUtils.Const.ScoreColumnKind.MulticlassClassification);

            return(CreatePipelineEnsemble <CommonOutputs.MulticlassClassificationOutput>(host, input.Models, ensemble));
        }