// Smoothing of leafs outputs:
        // 0 - no smoothing
        // 1 - maximal smoothing
        public void SmoothLeafOutputs(double parentOutput, double smoothing)
        {
            double myOutput = (1 - smoothing) * GetWeightedOutput() + smoothing * parentOutput;

            if (IsLeaf)
            {
                Tree.SetOutput(~NodeIndex, myOutput);
            }
            else
            {
                LteNode.SmoothLeafOutputs(myOutput, smoothing);
                GtNode.SmoothLeafOutputs(myOutput, smoothing);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Regularize a regression tree with smoothing paramter alpha.
        /// </summary>
        protected virtual void SmoothTree(InternalRegressionTree tree, double smoothing)
        {
            if (smoothing == 0.0)
            {
                return;
            }

            //Create recursive structure of the tree starting from root node
            var regularizer = new RecursiveRegressionTree(tree, TreeLearner.Partitioning, 0);

            //Perform bottom-up computation of weighted interior node output
            double rootNodeOutput = regularizer.GetWeightedOutput();

            //followed by top-down propagation of parent's output value
            regularizer.SmoothLeafOutputs(rootNodeOutput, smoothing);
        }