[][src]Trait opencv::ml::DTrees

pub trait DTrees: StatModel {
    pub fn as_raw_DTrees(&self) -> *const c_void;
pub fn as_raw_mut_DTrees(&mut self) -> *mut c_void; pub fn get_max_categories(&self) -> Result<i32> { ... }
pub fn set_max_categories(&mut self, val: i32) -> Result<()> { ... }
pub fn get_max_depth(&self) -> Result<i32> { ... }
pub fn set_max_depth(&mut self, val: i32) -> Result<()> { ... }
pub fn get_min_sample_count(&self) -> Result<i32> { ... }
pub fn set_min_sample_count(&mut self, val: i32) -> Result<()> { ... }
pub fn get_cv_folds(&self) -> Result<i32> { ... }
pub fn set_cv_folds(&mut self, val: i32) -> Result<()> { ... }
pub fn get_use_surrogates(&self) -> Result<bool> { ... }
pub fn set_use_surrogates(&mut self, val: bool) -> Result<()> { ... }
pub fn get_use1_se_rule(&self) -> Result<bool> { ... }
pub fn set_use1_se_rule(&mut self, val: bool) -> Result<()> { ... }
pub fn get_truncate_pruned_tree(&self) -> Result<bool> { ... }
pub fn set_truncate_pruned_tree(&mut self, val: bool) -> Result<()> { ... }
pub fn get_regression_accuracy(&self) -> Result<f32> { ... }
pub fn set_regression_accuracy(&mut self, val: f32) -> Result<()> { ... }
pub fn get_priors(&self) -> Result<Mat> { ... }
pub fn set_priors(&mut self, val: &Mat) -> Result<()> { ... }
pub fn get_roots(&self) -> Result<Vector<i32>> { ... }
pub fn get_nodes(&self) -> Result<Vector<DTrees_Node>> { ... }
pub fn get_splits(&self) -> Result<Vector<DTrees_Split>> { ... }
pub fn get_subsets(&self) -> Result<Vector<i32>> { ... } }

The class represents a single decision tree or a collection of decision trees.

The current public interface of the class allows user to train only a single decision tree, however the class is capable of storing multiple decision trees and using them for prediction (by summing responses or using a voting schemes), and the derived from DTrees classes (such as RTrees and Boost) use this capability to implement decision tree ensembles.

See also

@ref ml_intro_trees

Required methods

Loading content...

Provided methods

pub fn get_max_categories(&self) -> Result<i32>[src]

Cluster possible values of a categorical variable into K<=maxCategories clusters to find a suboptimal split. If a discrete variable, on which the training procedure tries to make a split, takes more than maxCategories values, the precise best subset estimation may take a very long time because the algorithm is exponential. Instead, many decision trees engines (including our implementation) try to find sub-optimal split in this case by clustering all the samples into maxCategories clusters that is some categories are merged together. The clustering is applied only in n > 2-class classification problems for categorical variables with N > max_categories possible values. In case of regression and 2-class classification the optimal split can be found efficiently without employing clustering, thus the parameter is not used in these cases. Default value is 10.

See also

setMaxCategories

pub fn set_max_categories(&mut self, val: i32) -> Result<()>[src]

Cluster possible values of a categorical variable into K<=maxCategories clusters to find a suboptimal split. If a discrete variable, on which the training procedure tries to make a split, takes more than maxCategories values, the precise best subset estimation may take a very long time because the algorithm is exponential. Instead, many decision trees engines (including our implementation) try to find sub-optimal split in this case by clustering all the samples into maxCategories clusters that is some categories are merged together. The clustering is applied only in n > 2-class classification problems for categorical variables with N > max_categories possible values. In case of regression and 2-class classification the optimal split can be found efficiently without employing clustering, thus the parameter is not used in these cases. Default value is 10.

See also

setMaxCategories getMaxCategories

pub fn get_max_depth(&self) -> Result<i32>[src]

The maximum possible depth of the tree. That is the training algorithms attempts to split a node while its depth is less than maxDepth. The root node has zero depth. The actual depth may be smaller if the other termination criteria are met (see the outline of the training procedure @ref ml_intro_trees "here"), and/or if the tree is pruned. Default value is INT_MAX.

See also

setMaxDepth

pub fn set_max_depth(&mut self, val: i32) -> Result<()>[src]

The maximum possible depth of the tree. That is the training algorithms attempts to split a node while its depth is less than maxDepth. The root node has zero depth. The actual depth may be smaller if the other termination criteria are met (see the outline of the training procedure @ref ml_intro_trees "here"), and/or if the tree is pruned. Default value is INT_MAX.

See also

setMaxDepth getMaxDepth

pub fn get_min_sample_count(&self) -> Result<i32>[src]

If the number of samples in a node is less than this parameter then the node will not be split.

Default value is 10.

See also

setMinSampleCount

pub fn set_min_sample_count(&mut self, val: i32) -> Result<()>[src]

If the number of samples in a node is less than this parameter then the node will not be split.

Default value is 10.

See also

setMinSampleCount getMinSampleCount

pub fn get_cv_folds(&self) -> Result<i32>[src]

If CVFolds > 1 then algorithms prunes the built decision tree using K-fold cross-validation procedure where K is equal to CVFolds. Default value is 10.

See also

setCVFolds

pub fn set_cv_folds(&mut self, val: i32) -> Result<()>[src]

If CVFolds > 1 then algorithms prunes the built decision tree using K-fold cross-validation procedure where K is equal to CVFolds. Default value is 10.

See also

setCVFolds getCVFolds

pub fn get_use_surrogates(&self) -> Result<bool>[src]

If true then surrogate splits will be built. These splits allow to work with missing data and compute variable importance correctly. Default value is false.

Note: currently it's not implemented.

See also

setUseSurrogates

pub fn set_use_surrogates(&mut self, val: bool) -> Result<()>[src]

If true then surrogate splits will be built. These splits allow to work with missing data and compute variable importance correctly. Default value is false.

Note: currently it's not implemented.

See also

setUseSurrogates getUseSurrogates

pub fn get_use1_se_rule(&self) -> Result<bool>[src]

If true then a pruning will be harsher. This will make a tree more compact and more resistant to the training data noise but a bit less accurate. Default value is true.

See also

setUse1SERule

pub fn set_use1_se_rule(&mut self, val: bool) -> Result<()>[src]

If true then a pruning will be harsher. This will make a tree more compact and more resistant to the training data noise but a bit less accurate. Default value is true.

See also

setUse1SERule getUse1SERule

pub fn get_truncate_pruned_tree(&self) -> Result<bool>[src]

If true then pruned branches are physically removed from the tree. Otherwise they are retained and it is possible to get results from the original unpruned (or pruned less aggressively) tree. Default value is true.

See also

setTruncatePrunedTree

pub fn set_truncate_pruned_tree(&mut self, val: bool) -> Result<()>[src]

If true then pruned branches are physically removed from the tree. Otherwise they are retained and it is possible to get results from the original unpruned (or pruned less aggressively) tree. Default value is true.

See also

setTruncatePrunedTree getTruncatePrunedTree

pub fn get_regression_accuracy(&self) -> Result<f32>[src]

Termination criteria for regression trees. If all absolute differences between an estimated value in a node and values of train samples in this node are less than this parameter then the node will not be split further. Default value is 0.01f

See also

setRegressionAccuracy

pub fn set_regression_accuracy(&mut self, val: f32) -> Result<()>[src]

Termination criteria for regression trees. If all absolute differences between an estimated value in a node and values of train samples in this node are less than this parameter then the node will not be split further. Default value is 0.01f

See also

setRegressionAccuracy getRegressionAccuracy

pub fn get_priors(&self) -> Result<Mat>[src]

The array of a priori class probabilities, sorted by the class label value.

The parameter can be used to tune the decision tree preferences toward a certain class. For example, if you want to detect some rare anomaly occurrence, the training base will likely contain much more normal cases than anomalies, so a very good classification performance will be achieved just by considering every case as normal. To avoid this, the priors can be specified, where the anomaly probability is artificially increased (up to 0.5 or even greater), so the weight of the misclassified anomalies becomes much bigger, and the tree is adjusted properly.

You can also think about this parameter as weights of prediction categories which determine relative weights that you give to misclassification. That is, if the weight of the first category is 1 and the weight of the second category is 10, then each mistake in predicting the second category is equivalent to making 10 mistakes in predicting the first category. Default value is empty Mat.

See also

setPriors

pub fn set_priors(&mut self, val: &Mat) -> Result<()>[src]

The array of a priori class probabilities, sorted by the class label value.

The parameter can be used to tune the decision tree preferences toward a certain class. For example, if you want to detect some rare anomaly occurrence, the training base will likely contain much more normal cases than anomalies, so a very good classification performance will be achieved just by considering every case as normal. To avoid this, the priors can be specified, where the anomaly probability is artificially increased (up to 0.5 or even greater), so the weight of the misclassified anomalies becomes much bigger, and the tree is adjusted properly.

You can also think about this parameter as weights of prediction categories which determine relative weights that you give to misclassification. That is, if the weight of the first category is 1 and the weight of the second category is 10, then each mistake in predicting the second category is equivalent to making 10 mistakes in predicting the first category. Default value is empty Mat.

See also

setPriors getPriors

pub fn get_roots(&self) -> Result<Vector<i32>>[src]

Returns indices of root nodes

pub fn get_nodes(&self) -> Result<Vector<DTrees_Node>>[src]

Returns all the nodes

all the node indices are indices in the returned vector

pub fn get_splits(&self) -> Result<Vector<DTrees_Split>>[src]

Returns all the splits

all the split indices are indices in the returned vector

pub fn get_subsets(&self) -> Result<Vector<i32>>[src]

Returns all the bitsets for categorical splits

Split::subsetOfs is an offset in the returned vector

Loading content...

Implementations

impl<'_> dyn DTrees + '_[src]

pub fn create() -> Result<Ptr<dyn DTrees>>[src]

Creates the empty model

The static method creates empty decision tree with the specified parameters. It should be then trained using train method (see StatModel::train). Alternatively, you can load the model from file using Algorithm::load<DTrees>(filename).

pub fn load(filepath: &str, node_name: &str) -> Result<Ptr<dyn DTrees>>[src]

Loads and creates a serialized DTrees from a file

Use DTree::save to serialize and store an DTree to disk. Load the DTree from this file again, by calling this function with the path to the file. Optionally specify the node for the file containing the classifier

Parameters

  • filepath: path to serialized DTree
  • nodeName: name of node containing the classifier

C++ default parameters

  • node_name: String()

Implementors

impl DTrees for PtrOfBoost[src]

impl DTrees for PtrOfDTrees[src]

impl DTrees for PtrOfRTrees[src]

Loading content...