@Namespace(value="cv::ml") @Properties(inherit=opencv_ml.class) public class StatModel extends AbstractStatModel
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
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 |
---|
StatModel(Pointer p)
Pointer cast constructor.
|
Modifier and Type | Method and Description |
---|---|
float |
calcError(TrainData data,
boolean test,
GpuMat resp) |
float |
calcError(TrainData data,
boolean test,
Mat resp)
\brief Computes error on the training or test dataset
|
float |
calcError(TrainData data,
boolean test,
UMat resp) |
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(GpuMat samples) |
float |
predict(GpuMat samples,
GpuMat results,
int flags) |
float |
predict(Mat samples) |
float |
predict(Mat samples,
Mat results,
int flags)
\brief Predicts response(s) for the provided sample(s)
|
float |
predict(UMat samples) |
float |
predict(UMat samples,
UMat results,
int flags) |
boolean |
train(GpuMat samples,
int layout,
GpuMat responses) |
boolean |
train(Mat samples,
int layout,
Mat responses)
\brief Trains the statistical model
|
boolean |
train(TrainData trainData) |
boolean |
train(TrainData trainData,
int flags)
\brief Trains the statistical model
|
boolean |
train(UMat samples,
int layout,
UMat responses) |
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, write, write
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, 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 StatModel(Pointer p)
Pointer.Pointer(Pointer)
.public int getVarCount()
@Cast(value="bool") public boolean empty()
Algorithm
@Cast(value="bool") public boolean isTrained()
@Cast(value="bool") public boolean isClassifier()
@Cast(value="bool") public boolean train(@opencv_core.Ptr 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 TrainData trainData)
@Cast(value="bool") public boolean train(@ByVal Mat samples, int layout, @ByVal Mat responses)
samples
- training sampleslayout
- See ml::SampleTypes.responses
- vector of responses associated with the training samples.@Cast(value="bool") public boolean train(@ByVal UMat samples, int layout, @ByVal UMat responses)
@Cast(value="bool") public boolean train(@ByVal GpuMat samples, int layout, @ByVal GpuMat responses)
public float calcError(@opencv_core.Ptr TrainData data, @Cast(value="bool") boolean test, @ByVal 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 calcError(@opencv_core.Ptr TrainData data, @Cast(value="bool") boolean test, @ByVal UMat resp)
public float calcError(@opencv_core.Ptr TrainData data, @Cast(value="bool") boolean test, @ByVal GpuMat resp)
public float predict(@ByVal Mat samples, @ByVal(nullValue="cv::OutputArray(cv::noArray())") 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 UMat samples, @ByVal(nullValue="cv::OutputArray(cv::noArray())") UMat results, int flags)
public float predict(@ByVal GpuMat samples, @ByVal(nullValue="cv::OutputArray(cv::noArray())") GpuMat results, int flags)
Copyright © 2019. All rights reserved.