internal EnsemblePredictor(IHostEnvironment env, PredictionKind kind,
                            FeatureSubsetModel <TScalarPredictor>[] models, IOutputCombiner <Single> combiner, Single[] weights = null)
     : base(env, LoaderSignature, models, combiner, weights)
 {
     PredictionKind = kind;
     InputType      = InitializeMappers(out _mappers);
 }
Beispiel #2
0
        private protected EnsembleModelParametersBase(IHostEnvironment env, string name, FeatureSubsetModel <TOutput>[] models,
                                                      IOutputCombiner <TOutput> combiner, Single[] weights)
            : base(env, name)
        {
            Host.Check(Utils.Size(models) > 0, "Ensemble was created with no models.");
            Host.Check(weights == null || weights.Length == models.Length);

            Models   = models;
            Combiner = combiner;
            Weights  = weights;
        }
Beispiel #3
0
        public static SchemaBindablePipelineEnsembleBase Create(IHostEnvironment env, IPredictorModel[] predictors, IOutputCombiner combiner, string scoreColumnKind)
        {
            switch (scoreColumnKind)
            {
            case MetadataUtils.Const.ScoreColumnKind.BinaryClassification:
                var binaryCombiner = combiner as IBinaryOutputCombiner;
                if (binaryCombiner == null)
                {
                    throw env.Except("Combiner type incompatible with score column kind");
                }
                return(new ImplOneWithCalibrator(env, predictors, binaryCombiner));

            case MetadataUtils.Const.ScoreColumnKind.Regression:
            case MetadataUtils.Const.ScoreColumnKind.AnomalyDetection:
                var regressionCombiner = combiner as IRegressionOutputCombiner;
                if (regressionCombiner == null)
                {
                    throw env.Except("Combiner type incompatible with score column kind");
                }
                return(new ImplOne(env, predictors, regressionCombiner, scoreColumnKind));

            case MetadataUtils.Const.ScoreColumnKind.MultiClassClassification:
                var vectorCombiner = combiner as IMultiClassOutputCombiner;
                if (vectorCombiner == null)
                {
                    throw env.Except("Combiner type incompatible with score column kind");
                }
                return(new ImplVec(env, predictors, vectorCombiner));

            default:
                throw env.Except("Unknown score kind");
            }
        }
Beispiel #4
0
 protected SchemaBindablePipelineEnsemble(IHostEnvironment env, IPredictorModel[] predictors,
                                          IOutputCombiner <T> combiner, string registrationName, string scoreColumnKind)
     : base(env, predictors, registrationName, scoreColumnKind)
 {
     Combiner = combiner;
 }
Beispiel #5
0
 public Bound(SchemaBindablePipelineEnsemble <T> parent, RoleMappedSchema schema)
     : base(parent, schema)
 {
     _combiner = parent.Combiner;
 }
 internal EnsembleDistributionPredictor(IHostEnvironment env, PredictionKind kind,
                                        FeatureSubsetModel <TDistPredictor>[] 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);
 }