@Namespace(value="cv::ml") public static class opencv_ml.StatModel extends opencv_ml.AbstractStatModel
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator
Modifier and Type | Field and Description |
---|---|
static int |
COMPRESSED_INPUT
enum cv::ml::StatModel::Flags
|
static int |
PREPROCESSED_INPUT
enum cv::ml::StatModel::Flags
|
static int |
RAW_OUTPUT
enum cv::ml::StatModel::Flags
|
static int |
UPDATE_MODEL
enum cv::ml::StatModel::Flags
|
Constructor and Description |
---|
opencv_ml.StatModel(Pointer p)
Pointer cast constructor.
|
Modifier and Type | Method and Description |
---|---|
float |
calcError(opencv_ml.TrainData data,
boolean test,
opencv_core.Mat resp)
\brief Computes error on the training or test dataset
|
boolean |
empty()
\brief Returns true if the Algorithm is empty (e.g.
|
int |
getVarCount()
\brief Returns the number of variables in training samples
|
boolean |
isClassifier()
\brief Returns true if the model is classifier
|
boolean |
isTrained()
\brief Returns true if the model is trained
|
float |
predict(opencv_core.Mat samples) |
float |
predict(opencv_core.Mat samples,
opencv_core.Mat results,
int flags)
\brief Predicts response(s) for the provided sample(s)
|
boolean |
train(opencv_core.Mat samples,
int layout,
opencv_core.Mat responses)
\brief Trains the statistical model
|
boolean |
train(opencv_ml.TrainData trainData) |
boolean |
train(opencv_ml.TrainData trainData,
int flags)
\brief Trains the statistical model
|
loadANN_MLP, loadANN_MLP, loadBoost, loadBoost, loadDTrees, loadDTrees, loadEM, loadEM, loadKNearest, loadKNearest, loadLogisticRegression, loadLogisticRegression, loadNormalBayesClassifier, loadNormalBayesClassifier, loadRTrees, loadRTrees, loadSVM, loadSVM
clear, getDefaultName, position, read, save, save, write
address, asBuffer, asByteBuffer, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, hashCode, isNull, limit, limit, maxBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, position, put, setNull, sizeof, toString, totalBytes, withDeallocator, zero
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 opencv_ml.StatModel(Pointer p)
Pointer.Pointer(Pointer)
.public int getVarCount()
@Cast(value="bool") public boolean empty()
opencv_core.Algorithm
empty
in class opencv_core.Algorithm
@Cast(value="bool") public boolean isTrained()
@Cast(value="bool") public boolean isClassifier()
@Cast(value="bool") public boolean train(@opencv_core.Ptr opencv_ml.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).@Cast(value="bool") public boolean train(@opencv_core.Ptr opencv_ml.TrainData trainData)
@Cast(value="bool") public boolean train(@ByVal opencv_core.Mat samples, int layout, @ByVal opencv_core.Mat responses)
samples
- training sampleslayout
- See ml::SampleTypes.responses
- vector of responses associated with the training samples.public float calcError(@opencv_core.Ptr opencv_ml.TrainData data, @Cast(value="bool") boolean test, @ByVal opencv_core.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(@ByVal opencv_core.Mat samples, @ByVal(nullValue="cv::noArray()") opencv_core.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(@ByVal opencv_core.Mat samples)
Copyright © 2016. All rights reserved.