public class StatModel extends Algorithm
Modifier and Type | Field and Description |
---|---|
static int |
COMPRESSED_INPUT |
static int |
PREPROCESSED_INPUT |
static int |
RAW_OUTPUT |
static int |
UPDATE_MODEL |
Modifier | Constructor and Description |
---|---|
protected |
StatModel(long addr) |
Modifier and Type | Method and Description |
---|---|
static StatModel |
__fromPtr__(long addr) |
float |
calcError(TrainData data,
boolean test,
Mat resp)
Computes error on the training or test dataset
|
boolean |
empty()
Returns true if the Algorithm is empty (e.g.
|
protected void |
finalize() |
int |
getVarCount()
Returns the number of variables in training samples
|
boolean |
isClassifier()
Returns true if the model is classifier
|
boolean |
isTrained()
Returns true if the model is trained
|
float |
predict(Mat samples)
Predicts response(s) for the provided sample(s)
|
float |
predict(Mat samples,
Mat results)
Predicts response(s) for the provided sample(s)
|
float |
predict(Mat samples,
Mat results,
int flags)
Predicts response(s) for the provided sample(s)
|
boolean |
train(Mat samples,
int layout,
Mat responses)
Trains the statistical model
|
boolean |
train(TrainData trainData)
Trains the statistical model
|
boolean |
train(TrainData trainData,
int flags)
Trains the statistical model
|
clear, getDefaultName, getNativeObjAddr, save
public static final int UPDATE_MODEL
public static final int RAW_OUTPUT
public static final int COMPRESSED_INPUT
public static final int PREPROCESSED_INPUT
public static StatModel __fromPtr__(long addr)
public boolean empty()
Algorithm
public boolean isClassifier()
public boolean isTrained()
public boolean train(Mat samples, int layout, Mat responses)
samples
- training sampleslayout
- See ml::SampleTypes.responses
- vector of responses associated with the training samples.public boolean train(TrainData trainData, int flags)
trainData
- training data that can be loaded from file using TrainData::loadFromCSV or
created with TrainData::create.flags
- optional flags, depending on the model. Some of the models can be updated with the
new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).public boolean train(TrainData trainData)
trainData
- training data that can be loaded from file using TrainData::loadFromCSV or
created with TrainData::create.
new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).public float calcError(TrainData data, boolean test, Mat resp)
data
- the training datatest
- 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%).public float predict(Mat samples, Mat results, int flags)
samples
- The input samples, floating-point matrixresults
- The optional output matrix of results.flags
- The optional flags, model-dependent. See cv::ml::StatModel::Flags.public float predict(Mat samples, Mat results)
samples
- The input samples, floating-point matrixresults
- The optional output matrix of results.public float predict(Mat samples)
samples
- The input samples, floating-point matrixpublic int getVarCount()
Generated on Wed Oct 9 2019 23:24:43 UTC / OpenCV 4.1.2