Example #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));
        }
Example #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));
        }
Example #3
0
 private EnsembleDistributionModelParameters(IHostEnvironment env, ModelLoadContext ctx)
     : base(env, RegistrationName, ctx)
 {
     PredictionKind       = (PredictionKind)ctx.Reader.ReadInt32();
     _probabilityCombiner = new Median(env);
     _inputType           = InitializeMappers(out _mappers);
     ComputeAveragedWeights(out _averagedWeights);
 }
Example #4
0
 /// <summary>
 /// Instantiate new ensemble model from existing sub-models.
 /// </summary>
 /// <param name="env">The host environment.</param>
 /// <param name="kind">The prediction kind <see cref="PredictionKind"/></param>
 /// <param name="models">Array of sub-models that you want to ensemble together.</param>
 /// <param name="combiner">The combiner class to use to ensemble the models.</param>
 /// <param name="weights">The weights assigned to each model to be ensembled.</param>
 internal EnsembleDistributionModelParameters(IHostEnvironment env, PredictionKind kind,
                                              FeatureSubsetModel <float>[] models, IOutputCombiner <Single> combiner, Single[] weights = null)
     : base(env, RegistrationName, models, combiner, weights)
 {
     PredictionKind       = kind;
     _probabilityCombiner = new Median(env);
     _inputType           = InitializeMappers(out _mappers);
     ComputeAveragedWeights(out _averagedWeights);
 }