Class cv::ml::NormalBayesClassifier#

Bayes classifier for normally distributed data. View details

#include <opencv2/ml.hpp>

Collaboration diagram for cv::ml::NormalBayesClassifier:

Public Types#

Public Types inherited from cv::ml::StatModel

Return

Name

Description

Flags

Public Member Functions#

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::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#

Bayes classifier for normally distributed data.

See also

ml_intro_bayes

Member Function Documentation#

predictProb()#

float cv::ml::NormalBayesClassifier::predictProb(
InputArray inputs,
OutputArray outputs,
OutputArray outputProbs,
int flags = 0 )

Python:

cv.ml.NormalBayesClassifier.predictProb(inputs[, outputs[, outputProbs[, flags]]]) -> retval, outputs, outputProbs

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.

create()#

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

Python:

cv.ml.NormalBayesClassifier.create() -> retval
cv.ml.NormalBayesClassifier_create() -> retval

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

load()#

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

Python:

cv.ml.NormalBayesClassifier.load(filepath[, nodeName]) -> retval
cv.ml.NormalBayesClassifier_load(filepath[, nodeName]) -> retval

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

Source file#

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