class cv::ml::Boost

Overview

Boosted tree classifier derived from DTrees. Moreā€¦

#include <ml.hpp>

class Boost: public cv::ml::DTrees
{
public:
    // enums

    enum Types;

    // methods

    virtual
    int
    getBoostType() const = 0;

    virtual
    int
    getWeakCount() const = 0;

    virtual
    double
    getWeightTrimRate() const = 0;

    virtual
    void
    setBoostType(int val) = 0;

    virtual
    void
    setWeakCount(int val) = 0;

    virtual
    void
    setWeightTrimRate(double val) = 0;

    static
    Ptr<Boost>
    create();

    static
    Ptr<Boost>
    load(
        const String& filepath,
        const String& nodeName = String()
        );
};

Inherited Members

public:
    // enums

    enum Flags;
    enum Flags;

    // classes

    class Node;
    class Split;

    // methods

    virtual
    void
    clear();

    virtual
    bool
    empty() const;

    virtual
    String
    getDefaultName() const;

    virtual
    void
    read(const FileNode& fn);

    virtual
    void
    save(const String& filename) const;

    virtual
    void
    write(FileStorage& fs) const;

    template <typename _Tp>
    static
    Ptr<_Tp>
    load(
        const String& filename,
        const String& objname = String()
        );

    template <typename _Tp>
    static
    Ptr<_Tp>
    loadFromString(
        const String& strModel,
        const String& objname = String()
        );

    template <typename _Tp>
    static
    Ptr<_Tp>
    read(const FileNode& fn);

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

    virtual
    bool
    empty() const;

    virtual
    int
    getVarCount() const = 0;

    virtual
    bool
    isClassifier() const = 0;

    virtual
    bool
    isTrained() const = 0;

    virtual
    float
    predict(
        InputArray samples,
        OutputArray results = noArray(),
        int flags = 0
        ) const = 0;

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

    virtual
    bool
    train(
        InputArray samples,
        int layout,
        InputArray responses
        );

    template <typename _Tp>
    static
    Ptr<_Tp>
    train(
        const Ptr<TrainData>& data,
        int flags = 0
        );

    virtual
    int
    getCVFolds() const = 0;

    virtual
    int
    getMaxCategories() const = 0;

    virtual
    int
    getMaxDepth() const = 0;

    virtual
    int
    getMinSampleCount() const = 0;

    virtual
    const std::vector<Node>&
    getNodes() const = 0;

    virtual
    cv::Mat
    getPriors() const = 0;

    virtual
    float
    getRegressionAccuracy() const = 0;

    virtual
    const std::vector<int>&
    getRoots() const = 0;

    virtual
    const std::vector<Split>&
    getSplits() const = 0;

    virtual
    const std::vector<int>&
    getSubsets() const = 0;

    virtual
    bool
    getTruncatePrunedTree() const = 0;

    virtual
    bool
    getUse1SERule() const = 0;

    virtual
    bool
    getUseSurrogates() const = 0;

    virtual
    void
    setCVFolds(int val) = 0;

    virtual
    void
    setMaxCategories(int val) = 0;

    virtual
    void
    setMaxDepth(int val) = 0;

    virtual
    void
    setMinSampleCount(int val) = 0;

    virtual
    void
    setPriors(const cv::Mat& val) = 0;

    virtual
    void
    setRegressionAccuracy(float val) = 0;

    virtual
    void
    setTruncatePrunedTree(bool val) = 0;

    virtual
    void
    setUse1SERule(bool val) = 0;

    virtual
    void
    setUseSurrogates(bool val) = 0;

    static
    Ptr<DTrees>
    create();

    static
    Ptr<DTrees>
    load(
        const String& filepath,
        const String& nodeName = String()
        );

protected:
    // methods

    void
    writeFormat(FileStorage& fs) const;

Detailed Documentation

Boosted tree classifier derived from DTrees.

See also:

Boosting

Methods

virtual
int
getBoostType() const = 0

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

See also:

setBoostType

virtual
int
getWeakCount() const = 0

The number of weak classifiers. Default value is 100.

See also:

setWeakCount

virtual
double
getWeightTrimRate() const = 0

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.

See also:

setWeightTrimRate

virtual
void
setBoostType(int val) = 0

See also:

getBoostType

virtual
void
setWeakCount(int val) = 0

See also:

getWeakCount

virtual
void
setWeightTrimRate(double val) = 0

See also:

getWeightTrimRate

static
Ptr<Boost>
create()

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

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

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