Class StatModel
- Namespace
- OpenCvSharp.ML
- Assembly
- OpenCvSharp.dll
Base class for statistical models in ML
public abstract class StatModel : Algorithm, IDisposable, ICvPtrHolder
- Inheritance
-
StatModel
- Implements
- Derived
- Inherited Members
Methods
CalcError(TrainData, bool, OutputArray)
Computes error on the training or test dataset
public virtual float CalcError(TrainData data, bool test, OutputArray resp)
Parameters
dataTrainDatathe training data
testboolif 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.
respOutputArraythe optional output responses.
Returns
Empty()
public virtual bool Empty()
Returns
GetVarCount()
Returns the number of variables in training samples
public virtual int GetVarCount()
Returns
IsClassifier()
Returns true if the model is classifier
public virtual bool IsClassifier()
Returns
IsTrained()
Returns true if the model is trained
public virtual bool IsTrained()
Returns
Predict(InputArray, OutputArray?, Flags)
Predicts response(s) for the provided sample(s)
public virtual float Predict(InputArray samples, OutputArray? results = null, StatModel.Flags flags = (StatModel.Flags)0)
Parameters
samplesInputArrayThe input samples, floating-point matrix
resultsOutputArrayThe optional output matrix of results.
flagsStatModel.FlagsThe optional flags, model-dependent.
Returns
Train(InputArray, SampleTypes, InputArray)
Trains the statistical model
public virtual bool Train(InputArray samples, SampleTypes layout, InputArray responses)
Parameters
samplesInputArraytraining samples
layoutSampleTypesSampleTypes value
responsesInputArrayvector of responses associated with the training samples.
Returns
Train(TrainData, int)
Trains the statistical model
public virtual bool Train(TrainData trainData, int flags = 0)
Parameters
trainDataTrainDatatraining data that can be loaded from file using TrainData::loadFromCSV or created with TrainData::create.
flagsintoptional 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).