예제 #1
0
            private readonly double _sigmoidParameter; // Parameter for scaling the loss

            public ObjectiveImpl(
                Dataset trainSet,
                bool[] trainSetLabels,
                double learningRate,
                double shrinkage,
                double sigmoidParameter,
                bool unbalancedSets,
                double maxTreeOutput,
                int getDerivativesSampleRate,
                bool bestStepRankingRegressionTrees,
                int rngSeed,
                IParallelTraining parallelTraining)
                : base(
                    trainSet,
                    learningRate,
                    shrinkage,
                    maxTreeOutput,
                    getDerivativesSampleRate,
                    bestStepRankingRegressionTrees,
                    rngSeed)
            {
                _sigmoidParameter = sigmoidParameter;
                _labels           = trainSetLabels;
                _unbalancedSets   = unbalancedSets;
                if (_unbalancedSets)
                {
                    BinaryClassificationTest.ComputeExampleCounts(_labels, out _npos, out _nneg);
                    Contracts.Check(_nneg > 0 && _npos > 0, "Only one class in training set.");
                }
                _parallelTraining = parallelTraining;
            }
예제 #2
0
        private void InitializeThreads()
        {
            ParallelTraining = new SingleTrainer();

            int numThreads = Args.NumThreads ?? Environment.ProcessorCount;

            if (Host.ConcurrencyFactor > 0 && numThreads > Host.ConcurrencyFactor)
            {
                using (var ch = Host.Start("GamTrainer"))
                {
                    numThreads = Host.ConcurrencyFactor;
                    ch.Warning("The number of threads specified in trainer arguments is larger than the concurrency factor "
                               + "setting of the environment. Using {0} training threads instead.", numThreads);
                }
            }

            ThreadTaskManager.Initialize(numThreads);
        }
예제 #3
0
 public ObjectiveImpl(Dataset trainSet, bool[] trainSetLabels, Arguments args, IParallelTraining parallelTraining)
     : base(
         trainSet,
         args.LearningRates,
         args.Shrinkage,
         args.MaxTreeOutput,
         args.GetDerivativesSampleRate,
         args.BestStepRankingRegressionTrees,
         args.RngSeed)
 {
     _labels         = trainSetLabels;
     _unbalancedSets = args.UnbalancedSets;
     if (_unbalancedSets)
     {
         BinaryClassificationTest.ComputeExampleCounts(_labels, out _npos, out _nneg);
         Contracts.Check(_nneg > 0 && _npos > 0, "Only one class in training set.");
     }
     _parallelTraining = parallelTraining;
 }
예제 #4
0
 private void InitializeThreads()
 {
     ParallelTraining = new SingleTrainer();
     ThreadTaskManager.Initialize(GamTrainerOptions.NumberOfThreads ?? Environment.ProcessorCount);
 }
 public RandomForestLeastSquaresTreeLearner(Dataset trainData, int numLeaves, int minDocsInLeaf, Double entropyCoefficient, Double featureFirstUsePenalty,
                                            Double featureReusePenalty, Double softmaxTemperature, int histogramPoolSize, int randomSeed, Double splitFraction, bool allowEmptyTrees,
                                            Double gainConfidenceLevel, int maxCategoricalGroupsPerNode, int maxCategoricalSplitPointsPerNode, bool quantileEnabled, int quantileSampleCount, IParallelTraining parallelTraining,
                                            double minDocsPercentageForCategoricalSplit, Bundle bundling, int minDocsForCategoricalSplit, double bias, IHost host)
     : base(trainData, numLeaves, minDocsInLeaf, entropyCoefficient, featureFirstUsePenalty, featureReusePenalty, softmaxTemperature, histogramPoolSize,
            randomSeed, splitFraction, false, allowEmptyTrees, gainConfidenceLevel, maxCategoricalGroupsPerNode, maxCategoricalSplitPointsPerNode, -1, parallelTraining,
            minDocsPercentageForCategoricalSplit, bundling, minDocsForCategoricalSplit, bias, host)
 {
     _quantileSampleCount = quantileSampleCount;
     _quantileEnabled     = quantileEnabled;
 }