Reduced Error Pruner¶
Module containing ReducedErrorPruner class.
- 
class pruneabletree.pruner_rep.ReducedErrorPruner(tree)[source]¶
- Pruner for decision trees that uses the Reduced Error Pruning (REP) technique [1] [2]. - Note that the given tree is modified in place. To keep a copy of the original, clone it first. - Parameters: - tree : Tree object
- The underlying tree object of a DecisionTreeClassifier (e.g. clf.tree_). 
 - See also - pruneabletree.prune.PruneableDecisionTreeClassifier,- pruneabletree.pruner_ebp.ErrorBasedPruner- References - [1] - (1, 2) J. Ross Quinlan. Simplifying decision trees. International journal of man-machine studies, 27(3):221-234, 1987. - [2] - (1, 2) Tapio Elomaa and Matti Kaariainen. An analysis of reduced error pruning. Journal of Artificial Intelligence Research, 15:163-187, 2001. - Methods - is_leaf(node_id)- Returns True if the given node is a leaf. - leaf_prediction(node_id)- Returns the class index of that the node with the given ID would predict. - num_actual_nodes(tree)- Returns the actual number of nodes in the given tree after pruning. - num_instances(node_id[, y_idx])- Returns the number of instances in a given node. - num_leaves(tree)- Returns the number of leaves. - prune(X_val, y_val)- Prunes the given tree using the given validation set. - to_leaf(node_id, depths)- Convert the node with the given ID to a leaf, pruning away its children. - 
prune(X_val, y_val)[source]¶
- Prunes the given tree using the given validation set. - Parameters: - X_val : array-like or sparse matrix, shape = [n_samples, n_features]
- The validation input samples. Internally, it will be converted to - dtype=np.float32and if a sparse matrix is provided to a sparse- csc_matrix.
- y_val : array-like, shape = [n_samples] or [n_samples, n_outputs]
- The target values (class labels) as integers or strings.