Beispiel #1
0
        private InternalTreeEnsemble GetBinaryEnsemble(int classID)
        {
            var res = new InternalTreeEnsemble();

            for (int i = classID; i < TrainedEnsemble.NumTrees; i += _numClass)
            {
                // Ignore dummy trees.
                if (TrainedEnsemble.GetTreeAt(i).NumLeaves > 1)
                {
                    res.AddTree(TrainedEnsemble.GetTreeAt(i));
                }
            }
            return(res);
        }
Beispiel #2
0
        private Ensemble GetBinaryEnsemble(int classID)
        {
            var      numClass = Objective.NumClass;
            Ensemble res      = new Ensemble();

            for (int i = classID; i < TrainedEnsemble.NumTrees; i += numClass)
            {
                // Ignore dummy trees
                if (TrainedEnsemble.GetTreeAt(i).NumLeaves > 1)
                {
                    res.AddTree(TrainedEnsemble.GetTreeAt(i));
                }
            }
            return(res);
        }
Beispiel #3
0
        public ValueMapper <VBuffer <Float>, VBuffer <Float> > GetMapper(Float[] quantiles)
        {
            return
                ((ref VBuffer <Float> src, ref VBuffer <Float> dst) =>
            {
                // REVIEW: Should make this more efficient - it repeatedly allocates too much stuff.
                Float[] weights = null;
                var distribution = TrainedEnsemble.GetDistribution(ref src, _quantileSampleCount, out weights);
                var qdist = new QuantileStatistics(distribution, weights);

                var values = dst.Values;
                if (Utils.Size(values) < quantiles.Length)
                {
                    values = new Float[quantiles.Length];
                }
                for (int i = 0; i < quantiles.Length; i++)
                {
                    values[i] = qdist.GetQuantile((Float)quantiles[i]);
                }
                dst = new VBuffer <Float>(quantiles.Length, values, dst.Indices);
            });
        }