Accord.MachineLearning.DecisionTrees.Pruning.ErrorBasedPruning.ErrorBasedPruning C# (CSharp) Method

ErrorBasedPruning() public method

Initializes a new instance of the ErrorBasedPruning class.
public ErrorBasedPruning ( DecisionTree tree, double inputs, int outputs ) : System
tree DecisionTree The tree to be pruned.
inputs double The pruning set inputs.
outputs int The pruning set outputs.
return System
        public ErrorBasedPruning(DecisionTree tree, double[][] inputs, int[] outputs)
        {
            this.tree = tree;
            this.inputs = inputs;
            this.outputs = outputs;
            this.subsets = new Dictionary<DecisionNode, List<int>>();
            this.actual = new int[outputs.Length];

            // Create the cache to store how many times a sample
            // passes through each decision node of the tree.
            //
            foreach (var node in tree)
                subsets[node] = new List<int>();

            // Compute the entire pruning set and track the path
            // taken by each observation during the reasoning.
            //
            for (int i = 0; i < inputs.Length; i++)
                trackDecisions(tree.Root, inputs[i], i);
        }