Class cv::ml::Boost#

Boosted tree classifier derived from DTrees. View details

#include <opencv2/ml.hpp>

Collaboration diagram for cv::ml::Boost:

Public Types#

enum Types {
    DISCRETE =0,
    REAL =1,
    LOGIT =2,
    GENTLE =3
}
Public Types inherited from cv::ml::DTrees

Return

Name

Description

Flags

Public Types inherited from cv::ml::StatModel

Return

Name

Description

Flags

Public Member Functions#

Public Member Functions inherited from cv::ml::DTrees

Return

Name

Description

int

getCVFolds()

int

getMaxCategories()

int

getMaxDepth()

int

getMinSampleCount()

const std::vector< Node > &

getNodes()

Returns all the nodes.

cv::Mat

getPriors()

The array of a priori class probabilities, sorted by the class label value.

float

getRegressionAccuracy()

const std::vector< int > &

getRoots()

Returns indices of root nodes.

const std::vector< Split > &

getSplits()

Returns all the splits.

const std::vector< int > &

getSubsets()

Returns all the bitsets for categorical splits.

bool

getTruncatePrunedTree()

bool

getUse1SERule()

bool

getUseSurrogates()

void

setCVFolds(int val)

void

setMaxCategories(int val)

void

setMaxDepth(int val)

void

setMinSampleCount(int val)

void

setPriors(const cv::Mat & val)

The array of a priori class probabilities, sorted by the class label value.

void

setRegressionAccuracy(float val)

void

setTruncatePrunedTree(bool val)

void

setUse1SERule(bool val)

void

setUseSurrogates(bool val)

Public Member Functions inherited from cv::ml::StatModel

Return

Name

Description

float

calcError(
    const Ptr< TrainData > & data,
    bool test,
    OutputArray resp )

Computes error on the training or test dataset.

bool

empty()

Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read.

int

getVarCount()

Returns the number of variables in training samples.

bool

isClassifier()

Returns true if the model is classifier.

bool

isTrained()

Returns true if the model is trained.

float

predict(
    InputArray samples,
    OutputArray results = noArray(),
    int flags = 0 )

Predicts response(s) for the provided sample(s)

bool

train(
    const Ptr< TrainData > & trainData,
    int flags = 0 )

Trains the statistical model.

bool

train(
    InputArray samples,
    int layout,
    InputArray responses )

Trains the statistical model.

Public Member Functions inherited from cv::Algorithm

Return

Name

Description

Algorithm()

~Algorithm()

void

clear()

Clears the algorithm state.

bool

empty()

Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read.

String

getDefaultName()

void

read(const FileNode & fn)

Reads algorithm parameters from a file storage.

void

save(const String & filename)

void

write(
    const Ptr< FileStorage > & fs,
    const String & name = String() )

void

write(FileStorage & fs)

Stores algorithm parameters in a file storage.

void

write(
    FileStorage & fs,
    const String & name )

Static Public Member Functions#

Static Public Member Functions inherited from cv::ml::DTrees

Return

Name

Description

static Ptr< DTrees >

create()

Creates the empty model.

static Ptr< DTrees >

load(
    const String & filepath,
    const String & nodeName = String() )

Loads and creates a serialized DTrees from a file.

Static Public Member Functions inherited from cv::ml::StatModel

Return

Name

Description

static Ptr< _Tp >

train(
    const Ptr< TrainData > & data,
    int flags = 0 )

Create and train model with default parameters.

Static Public Member Functions inherited from cv::Algorithm

Return

Name

Description

static Ptr< _Tp >

load(
    const String & filename,
    const String & objname = String() )

Loads algorithm from the file.

static Ptr< _Tp >

loadFromString(
    const String & strModel,
    const String & objname = String() )

Loads algorithm from a String.

static Ptr< _Tp >

read(const FileNode & fn)

Reads algorithm from the file node.

Additional Inherited Members#

Protected Member Functions inherited from cv::Algorithm

Return

Name

Description

void

writeFormat(FileStorage & fs)

Detailed Description#

Boosted tree classifier derived from DTrees.

See also

ml_intro_boost

Member Enumeration Documentation#

enum Types

DISCRETE
Python: cv.ml.Boost_DISCRETE

Discrete AdaBoost.

REAL
Python: cv.ml.Boost_REAL

Real AdaBoost. It is a technique that utilizes confidence-rated predictions and works well with categorical data.

LOGIT
Python: cv.ml.Boost_LOGIT

LogitBoost. It can produce good regression fits.

GENTLE
Python: cv.ml.Boost_GENTLE

Gentle AdaBoost. It puts less weight on outlier data points and for that reason is often good with regression data.

Member Function Documentation#

getBoostType()#

int cv::ml::Boost::getBoostType()

Python:

cv.ml.Boost.getBoostType() -> retval

Type of the boosting algorithm. See Boost::Types. Default value is Boost::REAL.

See also

setBoostType

getWeakCount()#

int cv::ml::Boost::getWeakCount()

Python:

cv.ml.Boost.getWeakCount() -> retval

The number of weak classifiers. Default value is 100.

See also

setWeakCount

getWeightTrimRate()#

double cv::ml::Boost::getWeightTrimRate()

Python:

cv.ml.Boost.getWeightTrimRate() -> retval

A threshold between 0 and 1 used to save computational time. Samples with summary weight \(\leq 1 - weight_trim_rate\) do not participate in the next iteration of training. Set this parameter to 0 to turn off this functionality. Default value is 0.95.

setBoostType()#

void cv::ml::Boost::setBoostType(int val)

Python:

cv.ml.Boost.setBoostType(val)

See also

getBoostType

setWeakCount()#

void cv::ml::Boost::setWeakCount(int val)

Python:

cv.ml.Boost.setWeakCount(val)

See also

getWeakCount

setWeightTrimRate()#

void cv::ml::Boost::setWeightTrimRate(double val)

Python:

cv.ml.Boost.setWeightTrimRate(val)

create()#

static Ptr< Boost > cv::ml::Boost::create()

Python:

cv.ml.Boost.create() -> retval
cv.ml.Boost_create() -> retval

Creates the empty model. Use StatModel::train to train the model, Algorithm::load<Boost>(filename) to load the pre-trained model.

load()#

static Ptr< Boost > cv::ml::Boost::load(
const String & filepath,
const String & nodeName = String() )

Python:

cv.ml.Boost.load(filepath[, nodeName]) -> retval
cv.ml.Boost_load(filepath[, nodeName]) -> retval

Loads and creates a serialized Boost from a file.

Use Boost::save to serialize and store an RTree to disk. Load the Boost 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 Boost

  • nodeName — name of node containing the classifier

Source file#

The documentation for this class was generated from the following file: