class cv::ml::NormalBayesClassifier

Overview

Bayes classifier for normally distributed data. Moreā€¦

#include <ml.hpp>

class NormalBayesClassifier: public cv::ml::StatModel
{
public:
    // methods

    virtual
    float
    predictProb(
        InputArray inputs,
        OutputArray outputs,
        OutputArray outputProbs,
        int flags = 0
        ) const = 0;

    static
    Ptr<NormalBayesClassifier>
    create();

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

Inherited Members

public:
    // enums

    enum Flags;

    // 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
        );

protected:
    // methods

    void
    writeFormat(FileStorage& fs) const;

Detailed Documentation

Bayes classifier for normally distributed data.

See also:

Normal Bayes Classifier

Methods

virtual
float
predictProb(
    InputArray inputs,
    OutputArray outputs,
    OutputArray outputProbs,
    int flags = 0
    ) const = 0

Predicts the response for sample(s).

The method estimates the most probable classes for input vectors. Input vectors (one or more) are stored as rows of the matrix inputs. In case of multiple input vectors, there should be one output vector outputs. The predicted class for a single input vector is returned by the method. The vector outputProbs contains the output probabilities corresponding to each element of result.

static
Ptr<NormalBayesClassifier>
create()

Creates empty model Use StatModel::train to train the model after creation.

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

Loads and creates a serialized NormalBayesClassifier from a file.

Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk. Load the NormalBayesClassifier 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 NormalBayesClassifier
nodeName name of node containing the classifier