Esempio n. 1
0
            public void AdjustTreeOutputs(IChannel ch, InternalRegressionTree tree,
                                          DocumentPartitioning partitioning, ScoreTracker trainingScores)
            {
                const double epsilon    = 1.4e-45;
                double       multiplier = LearningRate * Shrinkage;

                double[] means = null;
                if (!BestStepRankingRegressionTrees)
                {
                    means = _parallelTraining.GlobalMean(Dataset, tree, partitioning, Weights, false);
                }
                for (int l = 0; l < tree.NumLeaves; ++l)
                {
                    double output = tree.GetOutput(l);

                    if (BestStepRankingRegressionTrees)
                    {
                        output *= multiplier;
                    }
                    else
                    {
                        output = multiplier * (output + epsilon) / (means[l] + epsilon);
                    }

                    if (output > MaxTreeOutput)
                    {
                        output = MaxTreeOutput;
                    }
                    else if (output < -MaxTreeOutput)
                    {
                        output = -MaxTreeOutput;
                    }
                    tree.SetOutput(l, output);
                }
            }
Esempio n. 2
0
        internal override void AddScores(InternalRegressionTree tree, double multiplier)
        {
            _k++;
            double coeff = (_k - 1.0) / (_k + 2.0);

            int innerLoopSize = 1 + Dataset.NumDocs / BlockingThreadPool.NumThreads;   // +1 is to make sure we don't have a few left over at the end
            // REVIEW: This partitioning doesn't look optimal.
            // Probably make sence to investigate better ways of splitting data?
            var actions     = new Action[(int)Math.Ceiling(1.0 * Dataset.NumDocs / innerLoopSize)];
            var actionIndex = 0;

            for (int d = 0; d < Dataset.NumDocs; d += innerLoopSize)
            {
                var fromDoc = d;
                var toDoc   = Math.Min(d + innerLoopSize, Dataset.NumDocs);
                actions[actionIndex++] = () =>
                {
                    var featureBins = Dataset.GetFeatureBinRowwiseIndexer();
                    for (int doc = fromDoc; doc < toDoc; doc++)
                    {
                        double output = multiplier * tree.GetOutput(featureBins[doc]);
                        double newXK  = YK[doc] + output;
                        double newYK  = newXK + coeff * (newXK - XK[doc]);
                        XK[doc] = newXK;
                        YK[doc] = newYK;
                    }
                };
            }
            Parallel.Invoke(new ParallelOptions {
                MaxDegreeOfParallelism = BlockingThreadPool.NumThreads
            }, actions);
            SendScoresUpdatedMessage();
        }
Esempio n. 3
0
            public void AdjustTreeOutputs(IChannel ch, InternalRegressionTree tree, DocumentPartitioning partitioning, ScoreTracker trainingScores)
            {
                double shrinkage = LearningRate * Shrinkage;

                for (int l = 0; l < tree.NumLeaves; ++l)
                {
                    double output = tree.GetOutput(l) * shrinkage;
                    tree.SetOutput(l, output);
                }
            }