Bayes classifier for normally distributed data.
More...
#include <opencv2/ml.hpp>
|
virtual float | calcError (const Ptr< TrainData > &data, bool test, OutputArray resp) const |
| Computes error on the training or test dataset. More...
|
|
virtual void | clear () |
| Clears the algorithm state. More...
|
|
virtual bool | empty () const CV_OVERRIDE |
| Returns true if the Algorithm is empty (e.g. More...
|
|
virtual String | getDefaultName () const |
| Returns the algorithm string identifier. More...
|
|
virtual int | getVarCount () const =0 |
| Returns the number of variables in training samples. More...
|
|
virtual bool | isClassifier () const =0 |
| Returns true if the model is classifier. More...
|
|
virtual bool | isTrained () const =0 |
| Returns true if the model is trained. More...
|
|
virtual float | predict (InputArray samples, OutputArray results=noArray(), int flags=0) const =0 |
| Predicts response(s) for the provided sample(s) More...
|
|
virtual float | predictProb (InputArray inputs, OutputArray outputs, OutputArray outputProbs, int flags=0) const =0 |
| Predicts the response for sample(s). More...
|
|
virtual void | read (const FileNode &fn) |
| Reads algorithm parameters from a file storage. More...
|
|
virtual void | save (const String &filename) const |
| Saves the algorithm to a file. More...
|
|
virtual bool | train (const Ptr< TrainData > &trainData, int flags=0) |
| Trains the statistical model. More...
|
|
virtual bool | train (InputArray samples, int layout, InputArray responses) |
| Trains the statistical model. More...
|
|
virtual void | write (FileStorage &fs) const |
| Stores algorithm parameters in a file storage. More...
|
|
void | write (const Ptr< FileStorage > &fs, const String &name=String()) const |
| simplified API for language bindings This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
|
|
Bayes classifier for normally distributed data.
- See also
- Normal Bayes Classifier
◆ Flags
Predict options.
Enumerator |
---|
UPDATE_MODEL | |
RAW_OUTPUT | makes the method return the raw results (the sum), not the class label
|
COMPRESSED_INPUT | |
PREPROCESSED_INPUT | |
◆ calcError()
Computes error on the training or test dataset.
- Parameters
-
data | the training data |
test | if true, the error is computed over the test subset of the data, otherwise it's computed over the training subset of the data. Please note that if you loaded a completely different dataset to evaluate already trained classifier, you will probably want not to set the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so that the error is computed for the whole new set. Yes, this sounds a bit confusing. |
resp | the optional output responses. |
The method uses StatModel::predict to compute the error. For regression models the error is computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%).
◆ clear()
virtual void cv::Algorithm::clear |
( |
| ) |
|
|
inlinevirtualinherited |
◆ create()
◆ empty()
virtual bool cv::ml::StatModel::empty |
( |
| ) |
const |
|
virtualinherited |
Returns true if the Algorithm is empty (e.g.
in the very beginning or after unsuccessful read
Reimplemented from cv::Algorithm.
◆ getDefaultName()
virtual String cv::Algorithm::getDefaultName |
( |
| ) |
const |
|
virtualinherited |
◆ getVarCount()
virtual int cv::ml::StatModel::getVarCount |
( |
| ) |
const |
|
pure virtualinherited |
Returns the number of variables in training samples.
◆ isClassifier()
virtual bool cv::ml::StatModel::isClassifier |
( |
| ) |
const |
|
pure virtualinherited |
Returns true if the model is classifier.
◆ isTrained()
virtual bool cv::ml::StatModel::isTrained |
( |
| ) |
const |
|
pure virtualinherited |
Returns true if the model is trained.
◆ load()
◆ loadFromString()
template<typename _Tp >
static Ptr<_Tp> cv::Algorithm::loadFromString |
( |
const String & |
strModel, |
|
|
const String & |
objname = String() |
|
) |
| |
|
inlinestaticinherited |
◆ predict()
◆ predictProb()
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.
◆ read() [1/2]
virtual void cv::Algorithm::read |
( |
const FileNode & |
fn | ) |
|
|
inlinevirtualinherited |
◆ read() [2/2]
template<typename _Tp >
static Ptr<_Tp> cv::Algorithm::read |
( |
const FileNode & |
fn | ) |
|
|
inlinestaticinherited |
Reads algorithm from the file node.
This is static template method of Algorithm. It's usage is following (in the case of SVM):
Ptr<SVM> svm = Algorithm::read<SVM>(fsRead.root());
In order to make this method work, the derived class must overwrite Algorithm::read(const FileNode& fn) and also have static create() method without parameters (or with all the optional parameters)
◆ save()
virtual void cv::Algorithm::save |
( |
const String & |
filename | ) |
const |
|
virtualinherited |
Saves the algorithm to a file.
In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).
◆ train() [1/3]
virtual bool cv::ml::StatModel::train |
( |
const Ptr< TrainData > & |
trainData, |
|
|
int |
flags = 0 |
|
) |
| |
|
virtualinherited |
Trains the statistical model.
- Parameters
-
◆ train() [2/3]
Trains the statistical model.
- Parameters
-
samples | training samples |
layout | See ml::SampleTypes. |
responses | vector of responses associated with the training samples. |
◆ train() [3/3]
template<typename _Tp >
static Ptr<_Tp> cv::ml::StatModel::train |
( |
const Ptr< TrainData > & |
data, |
|
|
int |
flags = 0 |
|
) |
| |
|
inlinestaticinherited |
Create and train model with default parameters.
The class must implement static create()
method with no parameters or with all default parameter values
◆ write() [1/2]
virtual void cv::Algorithm::write |
( |
FileStorage & |
fs | ) |
const |
|
inlinevirtualinherited |
◆ write() [2/2]
simplified API for language bindings This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
◆ writeFormat()
void cv::Algorithm::writeFormat |
( |
FileStorage & |
fs | ) |
const |
|
protectedinherited |
The documentation for this class was generated from the following file: