Base class for statistical models in OpenCV ML.
More...
#include <opencv2/ml.hpp>
Base class for statistical models in OpenCV ML.
§ 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()
Python: |
---|
| retval, resp | = | cv.ml_StatModel.calcError( | data, test[, resp] | ) |
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%).
§ empty()
virtual bool cv::ml::StatModel::empty |
( |
| ) |
const |
|
virtual |
Python: |
---|
| retval | = | cv.ml_StatModel.empty( | | ) |
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read.
Reimplemented from cv::Algorithm.
§ getVarCount()
virtual int cv::ml::StatModel::getVarCount |
( |
| ) |
const |
|
pure virtual |
Python: |
---|
| retval | = | cv.ml_StatModel.getVarCount( | | ) |
Returns the number of variables in training samples.
§ isClassifier()
virtual bool cv::ml::StatModel::isClassifier |
( |
| ) |
const |
|
pure virtual |
Python: |
---|
| retval | = | cv.ml_StatModel.isClassifier( | | ) |
Returns true if the model is classifier.
§ isTrained()
virtual bool cv::ml::StatModel::isTrained |
( |
| ) |
const |
|
pure virtual |
Python: |
---|
| retval | = | cv.ml_StatModel.isTrained( | | ) |
Returns true if the model is trained.
§ predict()
Python: |
---|
| retval, results | = | cv.ml_StatModel.predict( | samples[, results[, flags]] | ) |
§ train() [1/3]
virtual bool cv::ml::StatModel::train |
( |
const Ptr< TrainData > & |
trainData, |
|
|
int |
flags = 0 |
|
) |
| |
|
virtual |
Python: |
---|
| retval | = | cv.ml_StatModel.train( | trainData[, flags] | ) |
| retval | = | cv.ml_StatModel.train( | samples, layout, responses | ) |
Trains the statistical model.
- Parameters
-
§ train() [2/3]
Python: |
---|
| retval | = | cv.ml_StatModel.train( | trainData[, flags] | ) |
| retval | = | cv.ml_StatModel.train( | samples, layout, responses | ) |
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 |
|
) |
| |
|
inlinestatic |
Python: |
---|
| retval | = | cv.ml_StatModel.train( | trainData[, flags] | ) |
| retval | = | cv.ml_StatModel.train( | samples, layout, responses | ) |
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: