Class cv::ml::RTrees#
The class implements the random forest predictor. View details
#include <opencv2/ml.hpp>Collaboration diagram for cv::ml::RTrees:
Public Types#
Public Types inherited from cv::ml::DTrees
Return |
Name |
Description |
|---|---|---|
Public Types inherited from cv::ml::StatModel
Return |
Name |
Description |
|---|---|---|
Public Member Functions#
Public Member Functions inherited from cv::ml::DTrees
Return |
Name |
Description |
|---|---|---|
|
||
|
||
|
||
|
||
|
Returns all the nodes. |
|
The array of a priori class probabilities, sorted by the class label value. |
||
|
||
|
Returns indices of root nodes. |
|
|
Returns all the splits. |
|
|
Returns all the bitsets for categorical splits. |
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
The array of a priori class probabilities, sorted by the class label value. |
|
|
||
|
||
|
||
|
Public Member Functions inherited from cv::ml::StatModel
Return |
Name |
Description |
|---|---|---|
|
|
Computes error on the training or test dataset. |
|
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read. |
|
|
Returns the number of variables in training samples. |
|
|
Returns true if the model is classifier. |
|
|
Returns true if the model is trained. |
|
|
|
Predicts response(s) for the provided sample(s) |
|
Trains the statistical model. |
|
|
|
Trains the statistical model. |
Public Member Functions inherited from cv::Algorithm
Return |
Name |
Description |
|---|---|---|
|
Clears the algorithm state. |
|
|
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read. |
|
|
Reads algorithm parameters from a file storage. |
|
|
||
|
|
|
|
Stores algorithm parameters in a file storage. |
|
|
Static Public Member Functions#
Static Public Member Functions inherited from cv::ml::DTrees
Static Public Member Functions inherited from cv::ml::StatModel
Return |
Name |
Description |
|---|---|---|
|
Create and train model with default parameters. |
Static Public Member Functions inherited from cv::Algorithm
Return |
Name |
Description |
|---|---|---|
|
|
Loads algorithm from the file. |
|
|
Loads algorithm from a String. |
|
Reads algorithm from the file node. |
Additional Inherited Members#
Protected Member Functions inherited from cv::Algorithm
Return |
Name |
Description |
|---|---|---|
|
Detailed Description#
The class implements the random forest predictor.
See also
ml_intro_rtrees
Member Function Documentation#
getActiveVarCount()#
int cv::ml::RTrees::getActiveVarCount()
Python:
cv.ml.RTrees.getActiveVarCount() -> retval
The size of the randomly selected subset of features at each tree node and that are used to find the best split(s). If you set it to 0 then the size will be set to the square root of the total number of features. Default value is 0.
See also
getCalculateVarImportance()#
bool cv::ml::RTrees::getCalculateVarImportance()
Python:
cv.ml.RTrees.getCalculateVarImportance() -> retval
If true then variable importance will be calculated and then it can be retrieved by RTrees::getVarImportance. Default value is false.
See also
getOOBError()#
double cv::ml::RTrees::getOOBError()
Returns the OOB error value, computed at the training stage when calcOOBError is set to true. If this flag was set to false, 0 is returned. The OOB error is also scaled by sample weighting.
getTermCriteria()#
TermCriteria cv::ml::RTrees::getTermCriteria()
Python:
cv.ml.RTrees.getTermCriteria() -> retval
The termination criteria that specifies when the training algorithm stops. Either when the specified number of trees is trained and added to the ensemble or when sufficient accuracy (measured as OOB error) is achieved. Typically the more trees you have the better the accuracy. However, the improvement in accuracy generally diminishes and asymptotes pass a certain number of trees. Also to keep in mind, the number of tree increases the prediction time linearly. Default value is TermCriteria(TermCriteria::MAX_ITERS + TermCriteria::EPS, 50, 0.1)
See also
getVarImportance()#
Mat cv::ml::RTrees::getVarImportance()
Python:
cv.ml.RTrees.getVarImportance() -> retval
Returns the variable importance array. The method returns the variable importance vector, computed at the training stage when CalculateVarImportance is set to true. If this flag was set to false, the empty matrix is returned.
getVotes()#
void cv::ml::RTrees::getVotes(
InputArray samples,
OutputArray results,
int flags )
Python:
cv.ml.RTrees.getVotes(samples, flags[, results]) -> results
Returns the result of each individual tree in the forest. In case the model is a regression problem, the method will return each of the trees’ results for each of the sample cases. If the model is a classifier, it will return a Mat with samples + 1 rows, where the first row gives the class number and the following rows return the votes each class had for each sample.
Parameters
samples— Array containing the samples for which votes will be calculated.results— Array where the result of the calculation will be written.flags— Flags for defining the type of RTrees.
setActiveVarCount()#
void cv::ml::RTrees::setActiveVarCount(int val)
Python:
cv.ml.RTrees.setActiveVarCount(val)
See also
setCalculateVarImportance()#
void cv::ml::RTrees::setCalculateVarImportance(bool val)
Python:
cv.ml.RTrees.setCalculateVarImportance(val)
See also
setTermCriteria()#
void cv::ml::RTrees::setTermCriteria(const TermCriteria & val)
Python:
cv.ml.RTrees.setTermCriteria(val)
See also
create()#
static Ptr< RTrees > cv::ml::RTrees::create()
Python:
cv.ml.RTrees.create() -> retval
cv.ml.RTrees_create() -> retval
Creates the empty model. Use StatModel::train to train the model, StatModel::train to create and train the model, Algorithm::load to load the pre-trained model.
load()#
static Ptr< RTrees > cv::ml::RTrees::load(
const String & filepath,
const String & nodeName = String() )
Python:
cv.ml.RTrees.load(filepath[, nodeName]) -> retval
cv.ml.RTrees_load(filepath[, nodeName]) -> retval
Loads and creates a serialized RTree from a file.
Use RTree::save to serialize and store an RTree to disk. Load the RTree 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 RTreenodeName— name of node containing the classifier
Source file#
The documentation for this class was generated from the following file:
opencv2/ml.hpp