OpenCV 2.4.3 (RC)

org.opencv.ml
Class CvRTrees

java.lang.Object
  extended by org.opencv.ml.CvStatModel
      extended by org.opencv.ml.CvRTrees
Direct Known Subclasses:
CvERTrees

public class CvRTrees
extends CvStatModel

The class implements the random forest predictor as described in the beginning of this section.

See Also:
org.opencv.ml.CvRTrees : public CvStatModel

Field Summary
 
Fields inherited from class org.opencv.ml.CvStatModel
nativeObj
 
Constructor Summary
  CvRTrees()
           
protected CvRTrees(long addr)
           
 
Method Summary
 void clear()
           
protected  void finalize()
           
 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.
 
Methods inherited from class org.opencv.ml.CvStatModel
load, load, save, save
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CvRTrees

public CvRTrees()

CvRTrees

protected CvRTrees(long addr)
Method Detail

clear

public void clear()

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class CvStatModel
Throws:
java.lang.Throwable

getVarImportance

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.

See Also:
org.opencv.ml.CvRTrees.getVarImportance

predict_prob

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.

Parameters:
sample - Sample for classification.
See Also:
org.opencv.ml.CvRTrees.predict_prob

predict_prob

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.

Parameters:
sample - Sample for classification.
missing - Optional missing measurement mask of the sample.
See Also:
org.opencv.ml.CvRTrees.predict_prob

predict

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).

Parameters:
sample - Sample for classification.
See Also:
org.opencv.ml.CvRTrees.predict

predict

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).

Parameters:
sample - Sample for classification.
missing - Optional missing measurement mask of the sample.
See Also:
org.opencv.ml.CvRTrees.predict

train

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.

Parameters:
trainData - a trainData
tflag - a tflag
responses - a responses
See Also:
org.opencv.ml.CvRTrees.train

train

public 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.

Parameters:
trainData - a trainData
tflag - a tflag
responses - a responses
varIdx - a varIdx
sampleIdx - a sampleIdx
varType - a varType
missingDataMask - a missingDataMask
params - a params
See Also:
org.opencv.ml.CvRTrees.train

Official OpenCV 2.4 Documentation