OpenCV 2.4.7

org.opencv.ml
Class CvGBTrees

java.lang.Object
  extended by org.opencv.ml.CvStatModel
      extended by org.opencv.ml.CvGBTrees

public class CvGBTrees
extends CvStatModel

The class implements the Gradient boosted tree model as described in the beginning of this section.

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

Field Summary
static int ABSOLUTE_LOSS
           
static int DEVIANCE_LOSS
           
static int HUBER_LOSS
           
static int SQUARED_LOSS
           
 
Constructor Summary
CvGBTrees()
          Default and training constructors.
CvGBTrees(Mat trainData, int tflag, Mat responses)
          Default and training constructors.
CvGBTrees(Mat trainData, int tflag, Mat responses, Mat varIdx, Mat sampleIdx, Mat varType, Mat missingDataMask, CvGBTreesParams params)
          Default and training constructors.
 
Method Summary
 void clear()
          Clears the model.
 float predict(Mat sample)
          Predicts a response for an input sample.
 float predict(Mat sample, Mat missing, Range slice, int k)
          Predicts a response for an input sample.
 boolean train(Mat trainData, int tflag, Mat responses)
          Trains a Gradient boosted tree model.
 boolean train(Mat trainData, int tflag, Mat responses, Mat varIdx, Mat sampleIdx, Mat varType, Mat missingDataMask, CvGBTreesParams params, boolean update)
          Trains a Gradient boosted tree model.
 
Methods inherited from class org.opencv.ml.CvStatModel
load, load, save, save
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ABSOLUTE_LOSS

public static final int ABSOLUTE_LOSS
See Also:
Constant Field Values

DEVIANCE_LOSS

public static final int DEVIANCE_LOSS
See Also:
Constant Field Values

HUBER_LOSS

public static final int HUBER_LOSS
See Also:
Constant Field Values

SQUARED_LOSS

public static final int SQUARED_LOSS
See Also:
Constant Field Values
Constructor Detail

CvGBTrees

public CvGBTrees()

Default and training constructors.

The constructors follow conventions of "CvStatModel.CvStatModel". See "CvStatModel.train" for parameters descriptions.

See Also:
org.opencv.ml.CvGBTrees.CvGBTrees

CvGBTrees

public CvGBTrees(Mat trainData,
                 int tflag,
                 Mat responses)

Default and training constructors.

The constructors follow conventions of "CvStatModel.CvStatModel". See "CvStatModel.train" for parameters descriptions.

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

CvGBTrees

public CvGBTrees(Mat trainData,
                 int tflag,
                 Mat responses,
                 Mat varIdx,
                 Mat sampleIdx,
                 Mat varType,
                 Mat missingDataMask,
                 CvGBTreesParams params)

Default and training constructors.

The constructors follow conventions of "CvStatModel.CvStatModel". See "CvStatModel.train" for parameters descriptions.

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.CvGBTrees.CvGBTrees
Method Detail

clear

public void clear()

Clears the model.

The function deletes the data set information and all the weak models and sets all internal variables to the initial state. The function is called in "CvGBTrees.train" and in the destructor.

See Also:
org.opencv.ml.CvGBTrees.clear

predict

public float predict(Mat sample)

Predicts a response for an input sample.

The method predicts the response corresponding to the given sample (see "Predicting with GBT"). The result is either the class label or the estimated function value. The "CvGBTrees.predict" method enables using the parallel version of the GBT model prediction if the OpenCV is built with the TBB library. In this case, predictions of single trees are computed in a parallel fashion.

Parameters:
sample - Input feature vector that has the same format as every training set element. If not all the variables were actually used during training, sample contains forged values at the appropriate places.
See Also:
org.opencv.ml.CvGBTrees.predict

predict

public float predict(Mat sample,
                     Mat missing,
                     Range slice,
                     int k)

Predicts a response for an input sample.

The method predicts the response corresponding to the given sample (see "Predicting with GBT"). The result is either the class label or the estimated function value. The "CvGBTrees.predict" method enables using the parallel version of the GBT model prediction if the OpenCV is built with the TBB library. In this case, predictions of single trees are computed in a parallel fashion.

Parameters:
sample - Input feature vector that has the same format as every training set element. If not all the variables were actually used during training, sample contains forged values at the appropriate places.
missing - Missing values mask, which is a dimensional matrix of the same size as sample having the CV_8U type. 1 corresponds to the missing value in the same position in the sample vector. If there are no missing values in the feature vector, an empty matrix can be passed instead of the missing mask.
slice - Parameter defining the part of the ensemble used for prediction.

If slice = Range.all(), all trees are used. Use this parameter to get predictions of the GBT models with different ensemble sizes learning only one model.

k - Number of tree ensembles built in case of the classification problem (see "Training GBT"). Use this parameter to change the output to sum of the trees' predictions in the k-th ensemble only. To get the total GBT model prediction, k value must be -1. For regression problems, k is also equal to -1.
See Also:
org.opencv.ml.CvGBTrees.predict

train

public boolean train(Mat trainData,
                     int tflag,
                     Mat responses)

Trains a Gradient boosted tree model.

The first train method follows the common template (see "CvStatModel.train"). Both tflag values (CV_ROW_SAMPLE, CV_COL_SAMPLE) are supported. trainData must be of the CV_32F type. responses must be a matrix of type CV_32S or CV_32F. In both cases it is converted into the CV_32F matrix inside the training procedure. varIdx and sampleIdx must be a list of indices (CV_32S) or a mask (CV_8U or CV_8S). update is a dummy parameter.

The second form of "CvGBTrees.train" function uses "CvMLData" as a data set container. update is still a dummy parameter.

All parameters specific to the GBT model are passed into the training function as a "CvGBTreesParams" structure.

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

train

public boolean train(Mat trainData,
                     int tflag,
                     Mat responses,
                     Mat varIdx,
                     Mat sampleIdx,
                     Mat varType,
                     Mat missingDataMask,
                     CvGBTreesParams params,
                     boolean update)

Trains a Gradient boosted tree model.

The first train method follows the common template (see "CvStatModel.train"). Both tflag values (CV_ROW_SAMPLE, CV_COL_SAMPLE) are supported. trainData must be of the CV_32F type. responses must be a matrix of type CV_32S or CV_32F. In both cases it is converted into the CV_32F matrix inside the training procedure. varIdx and sampleIdx must be a list of indices (CV_32S) or a mask (CV_8U or CV_8S). update is a dummy parameter.

The second form of "CvGBTrees.train" function uses "CvMLData" as a data set container. update is still a dummy parameter.

All parameters specific to the GBT model are passed into the training function as a "CvGBTreesParams" structure.

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
update - a update
See Also:
org.opencv.ml.CvGBTrees.train

OpenCV 2.4.7 Documentation