org.opencv.ml
public class CvBoost extends CvStatModel
Boosted tree classifier derived from "CvStatModel".
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT |
static int |
DISCRETE |
static int |
GENTLE |
static int |
GINI |
static int |
LOGIT |
static int |
MISCLASS |
static int |
REAL |
static int |
SQERR |
Constructor and Description |
---|
CvBoost()
Default and training constructors.
|
CvBoost(Mat trainData,
int tflag,
Mat responses)
Default and training constructors.
|
CvBoost(Mat trainData,
int tflag,
Mat responses,
Mat varIdx,
Mat sampleIdx,
Mat varType,
Mat missingDataMask,
CvBoostParams params)
Default and training constructors.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
float |
predict(Mat sample)
Predicts a response for an input sample.
|
float |
predict(Mat sample,
Mat missing,
Range slice,
boolean rawMode,
boolean returnSum)
Predicts a response for an input sample.
|
void |
prune(Range slice)
Removes the specified weak classifiers.
|
boolean |
train(Mat trainData,
int tflag,
Mat responses)
Trains a boosted tree classifier.
|
boolean |
train(Mat trainData,
int tflag,
Mat responses,
Mat varIdx,
Mat sampleIdx,
Mat varType,
Mat missingDataMask,
CvBoostParams params,
boolean update)
Trains a boosted tree classifier.
|
load, load, save, save
public static final int DEFAULT
public static final int DISCRETE
public static final int GENTLE
public static final int GINI
public static final int LOGIT
public static final int MISCLASS
public static final int REAL
public static final int SQERR
public CvBoost()
Default and training constructors.
The constructors follow conventions of "CvStatModel.CvStatModel". See "CvStatModel.train" for parameters descriptions.
public CvBoost(Mat trainData, int tflag, Mat responses)
Default and training constructors.
The constructors follow conventions of "CvStatModel.CvStatModel". See "CvStatModel.train" for parameters descriptions.
trainData
- a trainDatatflag
- a tflagresponses
- a responsespublic CvBoost(Mat trainData, int tflag, Mat responses, Mat varIdx, Mat sampleIdx, Mat varType, Mat missingDataMask, CvBoostParams params)
Default and training constructors.
The constructors follow conventions of "CvStatModel.CvStatModel". See "CvStatModel.train" for parameters descriptions.
trainData
- a trainDatatflag
- a tflagresponses
- a responsesvarIdx
- a varIdxsampleIdx
- a sampleIdxvarType
- a varTypemissingDataMask
- a missingDataMaskparams
- a paramspublic void clear()
public float predict(Mat sample)
Predicts a response for an input sample.
The method runs the sample through the trees in the ensemble and returns the output class label based on the weighted voting.
sample
- Input sample.public float predict(Mat sample, Mat missing, Range slice, boolean rawMode, boolean returnSum)
Predicts a response for an input sample.
The method runs the sample through the trees in the ensemble and returns the output class label based on the weighted voting.
sample
- Input sample.missing
- Optional mask of missing measurements. To handle missing
measurements, the weak classifiers must include surrogate splits (see
CvDTreeParams.use_surrogates
).slice
- Continuous subset of the sequence of weak classifiers to be used
for prediction. By default, all the weak classifiers are used.rawMode
- Normally, it should be set to false
.returnSum
- If true
then return sum of votes instead of the
class label.public void prune(Range slice)
Removes the specified weak classifiers.
The method removes the specified weak classifiers from the sequence.
Note: Do not confuse this method with the pruning of individual decision trees, which is currently not supported.
slice
- Continuous subset of the sequence of weak classifiers to be
removed.public boolean train(Mat trainData, int tflag, Mat responses)
Trains a boosted tree classifier.
The train method follows the common template of "CvStatModel.train". The responses must be categorical, which means that boosted trees cannot be built for regression, and there should be two classes.
trainData
- a trainDatatflag
- a tflagresponses
- a responsespublic boolean train(Mat trainData, int tflag, Mat responses, Mat varIdx, Mat sampleIdx, Mat varType, Mat missingDataMask, CvBoostParams params, boolean update)
Trains a boosted tree classifier.
The train method follows the common template of "CvStatModel.train". The responses must be categorical, which means that boosted trees cannot be built for regression, and there should be two classes.
trainData
- a trainDatatflag
- a tflagresponses
- a responsesvarIdx
- a varIdxsampleIdx
- a sampleIdxvarType
- a varTypemissingDataMask
- a missingDataMaskparams
- a paramsupdate
- Specifies whether the classifier needs to be updated
(true
, the new weak tree classifiers added to the existing
ensemble) or the classifier needs to be rebuilt from scratch
(false
).