Exemple #1
0
        internal override void AddScores(InternalRegressionTree tree, DocumentPartitioning partitioning, double multiplier)
        {
            _k++;
            double coeff   = (_k - 1.0) / (_k + 2.0);
            var    actions = new Action[tree.NumLeaves];

            Parallel.For(0, tree.NumLeaves, new ParallelOptions {
                MaxDegreeOfParallelism = BlockingThreadPool.NumThreads
            },
                         (int leaf) =>
            {
                int[] documents;
                int begin;
                int count;
                partitioning.ReferenceLeafDocuments(leaf, out documents, out begin, out count);
                double output = tree.LeafValue(leaf) * multiplier;
                for (int i = begin; i < begin + count; ++i)
                {
                    int doc      = documents[i];
                    double newXK = YK[doc] + output;
                    double newYK = newXK + coeff * (newXK - XK[doc]);
                    XK[doc]      = newXK;
                    YK[doc]      = newYK;
                }
            });
            SendScoresUpdatedMessage();
        }
Exemple #2
0
        //Use faster method for score update with Partitioning
        // suitable for TrainSet
        internal virtual void AddScores(InternalRegressionTree tree, DocumentPartitioning partitioning, double multiplier)
        {
            Parallel.For(0, tree.NumLeaves, new ParallelOptions {
                MaxDegreeOfParallelism = BlockingThreadPool.NumThreads
            }, (leaf) =>
            {
                int[] documents;
                int begin;
                int count;
                partitioning.ReferenceLeafDocuments(leaf, out documents, out begin, out count);
                double output = tree.LeafValue(leaf) * multiplier;
                for (int i = begin; i < begin + count; ++i)
                {
                    Scores[documents[i]] += output;
                }
            });

            SendScoresUpdatedMessage();
        }