org.opencv.ml
public class CvRTrees extends CvStatModel
The class implements the random forest predictor as described in the beginning of this section.
Constructor and Description |
---|
CvRTrees() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
Mat |
getVarImportance()
Returns the variable importance array.
|
float |
predict_prob(Mat sample)
Returns a fuzzy-predicted class label.
|
float |
predict_prob(Mat sample,
Mat missing)
Returns a fuzzy-predicted class label.
|
float |
predict(Mat sample)
Predicts the output for an input sample.
|
float |
predict(Mat sample,
Mat missing)
Predicts the output for an input sample.
|
boolean |
train(Mat trainData,
int tflag,
Mat responses)
Trains the Random Trees model.
|
boolean |
train(Mat trainData,
int tflag,
Mat responses,
Mat varIdx,
Mat sampleIdx,
Mat varType,
Mat missingDataMask,
CvRTParams params)
Trains the Random Trees model.
|
load, load, save, save
public void clear()
public Mat getVarImportance()
Returns the variable importance array.
The method returns the variable importance vector, computed at the training
stage when CvRTParams.calc_var_importance
is set to true. If
this flag was set to false, the NULL
pointer is returned. This
differs from the decision trees where variable importance can be computed
anytime after the training.
public float predict_prob(Mat sample)
Returns a fuzzy-predicted class label.
The function works for binary classification problems only. It returns the number between 0 and 1. This number represents probability or confidence of the sample belonging to the second class. It is calculated as the proportion of decision trees that classified the sample to the second class.
sample
- Sample for classification.public float predict_prob(Mat sample, Mat missing)
Returns a fuzzy-predicted class label.
The function works for binary classification problems only. It returns the number between 0 and 1. This number represents probability or confidence of the sample belonging to the second class. It is calculated as the proportion of decision trees that classified the sample to the second class.
sample
- Sample for classification.missing
- Optional missing measurement mask of the sample.public float predict(Mat sample)
Predicts the output for an input sample.
The input parameters of the prediction method are the same as in "CvDTree.predict" but the return value type is different. This method returns the cumulative result from all the trees in the forest (the class that receives the majority of voices, or the mean of the regression function estimates).
sample
- Sample for classification.public float predict(Mat sample, Mat missing)
Predicts the output for an input sample.
The input parameters of the prediction method are the same as in "CvDTree.predict" but the return value type is different. This method returns the cumulative result from all the trees in the forest (the class that receives the majority of voices, or the mean of the regression function estimates).
sample
- Sample for classification.missing
- Optional missing measurement mask of the sample.public boolean train(Mat trainData, int tflag, Mat responses)
Trains the Random Trees model.
The method "CvRTrees.train" is very similar to the method "CvDTree.train"
and follows the generic method "CvStatModel.train" conventions. All the
parameters specific to the algorithm training are passed as a "CvRTParams"
instance. The estimate of the training error (oob-error
) is
stored in the protected class member oob_error
.
The function is parallelized with the TBB library.
trainData
- a trainDatatflag
- a tflagresponses
- a responsespublic boolean train(Mat trainData, int tflag, Mat responses, Mat varIdx, Mat sampleIdx, Mat varType, Mat missingDataMask, CvRTParams params)
Trains the Random Trees model.
The method "CvRTrees.train" is very similar to the method "CvDTree.train"
and follows the generic method "CvStatModel.train" conventions. All the
parameters specific to the algorithm training are passed as a "CvRTParams"
instance. The estimate of the training error (oob-error
) is
stored in the protected class member oob_error
.
The function is parallelized with the TBB library.
trainData
- a trainDatatflag
- a tflagresponses
- a responsesvarIdx
- a varIdxsampleIdx
- a sampleIdxvarType
- a varTypemissingDataMask
- a missingDataMaskparams
- a params