OpenCV  4.1.0
Open Source Computer Vision
Public Member Functions | Static Public Member Functions | List of all members
cv::ml::NormalBayesClassifier Class Referenceabstract

Bayes classifier for normally distributed data. More...

#include <opencv2/ml.hpp>

Inheritance diagram for cv::ml::NormalBayesClassifier:
cv::ml::StatModel cv::Algorithm

Public Member Functions

virtual float predictProb (InputArray inputs, OutputArray outputs, OutputArray outputProbs, int flags=0) const =0
 Predicts the response for sample(s).
 
- Public Member Functions inherited from cv::ml::StatModel
virtual float calcError (const Ptr< TrainData > &data, bool test, OutputArray resp) const
 Computes error on the training or test dataset.
 
virtual bool empty () const CV_OVERRIDE
 Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read.
 
virtual int getVarCount () const =0
 Returns the number of variables in training samples.
 
virtual bool isClassifier () const =0
 Returns true if the model is classifier.
 
virtual bool isTrained () const =0
 Returns true if the model is trained.
 
virtual float predict (InputArray samples, OutputArray results=noArray(), int flags=0) const =0
 Predicts response(s) for the provided sample(s)
 
virtual bool train (const Ptr< TrainData > &trainData, int flags=0)
 Trains the statistical model.
 
virtual bool train (InputArray samples, int layout, InputArray responses)
 Trains the statistical model.
 
- Public Member Functions inherited from cv::Algorithm
 Algorithm ()
 
virtual ~Algorithm ()
 
virtual void clear ()
 Clears the algorithm state.
 
virtual String getDefaultName () const
 
virtual void read (const FileNode &fn)
 Reads algorithm parameters from a file storage.
 
virtual void save (const String &filename) const
 
virtual void write (FileStorage &fs) const
 Stores algorithm parameters in a file storage.
 
void write (const Ptr< FileStorage > &fs, const String &name=String()) const
 simplified API for language bindingsThis is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Static Public Member Functions

static Ptr< NormalBayesClassifiercreate ()
 
static Ptr< NormalBayesClassifierload (const String &filepath, const String &nodeName=String())
 Loads and creates a serialized NormalBayesClassifier from a file.
 
- Static Public Member Functions inherited from cv::ml::StatModel
template<typename _Tp >
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
template<typename _Tp >
static Ptr< _Tp > load (const String &filename, const String &objname=String())
 Loads algorithm from the file.
 
template<typename _Tp >
static Ptr< _Tp > loadFromString (const String &strModel, const String &objname=String())
 Loads algorithm from a String.
 
template<typename _Tp >
static Ptr< _Tp > read (const FileNode &fn)
 Reads algorithm from the file node.
 

Additional Inherited Members

- Public Types inherited from cv::ml::StatModel
enum  Flags {
  UPDATE_MODEL = 1,
  RAW_OUTPUT =1,
  COMPRESSED_INPUT =2,
  PREPROCESSED_INPUT =4
}
 
- Protected Member Functions inherited from cv::Algorithm
void writeFormat (FileStorage &fs) const
 

Detailed Description

Bayes classifier for normally distributed data.

See Also
Normal Bayes Classifier

Member Function Documentation

static Ptr<NormalBayesClassifier> cv::ml::NormalBayesClassifier::create ( )
static
Python:
retval=cv.ml.NormalBayesClassifier_create()
Creates empty model

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

static Ptr<NormalBayesClassifier> cv::ml::NormalBayesClassifier::load ( const String filepath,
const String nodeName = String() 
)
static
Python:
retval=cv.ml.NormalBayesClassifier_load(filepath[, nodeName])

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
filepathpath to serialized NormalBayesClassifier
nodeNamename of node containing the classifier
virtual float cv::ml::NormalBayesClassifier::predictProb ( InputArray  inputs,
OutputArray  outputs,
OutputArray  outputProbs,
int  flags = 0 
) const
pure virtual
Python:
retval, outputs, outputProbs=cv.ml_NormalBayesClassifier.predictProb(inputs[, outputs[, outputProbs[, flags]]])

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.


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