Base class for statistical models in OpenCV ML.
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.
|
|
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.
|
|
| 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.
|
|
|
template<typename _Tp > |
static Ptr< _Tp > | train (const Ptr< TrainData > &data, int flags=0) |
| Create and train model with default parameters.
|
|
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.
|
|
Base class for statistical models in OpenCV ML.
Predict options
Enumerator |
---|
UPDATE_MODEL |
|
RAW_OUTPUT |
makes the method return the raw results (the sum), not the class label
|
COMPRESSED_INPUT |
|
PREPROCESSED_INPUT |
|
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%).
virtual bool cv::ml::StatModel::empty |
( |
| ) |
const |
|
virtual |
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read.
Reimplemented from cv::Algorithm.
virtual int cv::ml::StatModel::getVarCount |
( |
| ) |
const |
|
pure virtual |
Returns the number of variables in training samples.
virtual bool cv::ml::StatModel::isClassifier |
( |
| ) |
const |
|
pure virtual |
Returns true if the model is classifier.
virtual bool cv::ml::StatModel::isTrained |
( |
| ) |
const |
|
pure virtual |
Returns true if the model is trained.
virtual bool cv::ml::StatModel::train |
( |
const Ptr< TrainData > & |
trainData, |
|
|
int |
flags = 0 |
|
) |
| |
|
virtual |
Trains the statistical model.
- Parameters
-
Trains the statistical model.
- Parameters
-
samples | training samples |
layout | See ml::SampleTypes. |
responses | vector of responses associated with the training samples. |
template<typename _Tp >
static Ptr<_Tp> cv::ml::StatModel::train |
( |
const Ptr< TrainData > & |
data, |
|
|
int |
flags = 0 |
|
) |
| |
|
inlinestatic |
Create and train model with default parameters.
The class must implement static create()
method with no parameters or with all default parameter values
The documentation for this class was generated from the following file: