ErrorBasedPruning Class |
Namespace: Accord.MachineLearning.DecisionTrees.Pruning
The ErrorBasedPruning type exposes the following members.
Name | Description | |
---|---|---|
ErrorBasedPruning |
Initializes a new instance of the ErrorBasedPruning class.
|
Name | Description | |
---|---|---|
Threshold |
Gets or sets the minimum allowed gain threshold
to prune the tree. Default is 0.01.
|
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Run |
Computes one pass of the pruning algorithm.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(Type) | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) | |
ToT | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) |
References:
// Suppose you have the following input and output data // and would like to learn the relationship between the // inputs and outputs by using a Decision Tree: double[][] inputs = ... int[] output = ... // To prune a decision tree, we need to split your data into // training and pruning groups. Let's say we have 100 samples, // and would like to reserve 50 samples for training, and 50 // for pruning: // Gather the first half for the training set var trainingInputs = inputs.Submatrix(0, 49); var trainingOutput = output.Submatrix(0, 49); // Gather the second hand data for pruning var pruningInputs = inputs.Submatrix(50, 99); var pruningOutput = output.Submatrix(50, 99); // Create the decision tree DecisionTree tree = new DecisionTree( ... ); // Learn our tree using the training data C45Learning c45 = new C45Learning(tree); double error = c45.Run(trainingInputs, trainingOutput); // Now we can attempt to prune the tree using the pruning groups ErrorBasedPruning prune = new ErrorBasedPruning(tree, pruningInputs, pruningOutput); // Gain threshold prune.Threshold = 0.1; double lastError; double error = Double.PositiveInfinity; do { // Now we can start pruning the tree as // long as the error doesn't increase lastError = error; error = prune.Run(); } while (error < lastError);