Beispiel #1
0
        public IEstimator <ITransformer> ToEstimator()
        {
            IEstimator <ITransformer> pipeline = new EstimatorChain <ITransformer>();

            // Append each transformer to the pipeline
            foreach (var transform in Transforms)
            {
                if (transform.Estimator != null)
                {
                    pipeline = pipeline.Append(transform.Estimator);
                }
            }

            // Get learner
            var learner = Trainer.BuildTrainer();

            if (_cacheBeforeTrainer)
            {
                pipeline = pipeline.AppendCacheCheckpoint(_context);
            }

            // Append learner to pipeline
            pipeline = pipeline.Append(learner);

            // Append each post-trainer transformer to the pipeline
            foreach (var transform in TransformsPostTrainer)
            {
                if (transform.Estimator != null)
                {
                    pipeline = pipeline.Append(transform.Estimator);
                }
            }

            return(pipeline);
        }
Beispiel #2
0
        public static SuggestedPipeline Build(MLContext context,
                                              ICollection <SuggestedTransform> transforms,
                                              ICollection <SuggestedTransform> transformsPostTrainer,
                                              SuggestedTrainer trainer,
                                              CacheBeforeTrainer cacheBeforeTrainerSettings)
        {
            var trainerInfo = trainer.BuildTrainer().Info;

            AddNormalizationTransforms(context, trainerInfo, transforms);
            var cacheBeforeTrainer = ShouldCacheBeforeTrainer(trainerInfo, cacheBeforeTrainerSettings);

            return(new SuggestedPipeline(transforms, transformsPostTrainer, trainer, context, cacheBeforeTrainer));
        }