Class StatModel
Base class for statistical models in ML
Inheritance
Implements
Inherited Members
Namespace: OpenCvSharp.ML
Assembly: OpenCvSharp.dll
Syntax
public abstract class StatModel : Algorithm, ICvPtrHolder
Methods
| Improve this Doc View SourceCalcError(TrainData, Boolean, OutputArray)
Computes error on the training or test dataset
Declaration
public virtual float CalcError(TrainData data, bool test, OutputArray resp)
Parameters
Type | Name | Description |
---|---|---|
TrainData | data | the training data |
System.Boolean | 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. |
OutputArray | resp | the optional output responses. |
Returns
Type | Description |
---|---|
System.Single |
Empty()
Declaration
public virtual bool Empty()
Returns
Type | Description |
---|---|
System.Boolean |
GetVarCount()
Returns the number of variables in training samples
Declaration
public virtual int GetVarCount()
Returns
Type | Description |
---|---|
System.Int32 |
IsClassifier()
Returns true if the model is classifier
Declaration
public virtual bool IsClassifier()
Returns
Type | Description |
---|---|
System.Boolean |
IsTrained()
Returns true if the model is trained
Declaration
public virtual bool IsTrained()
Returns
Type | Description |
---|---|
System.Boolean |
Predict(InputArray, OutputArray, StatModel.Flags)
Predicts response(s) for the provided sample(s)
Declaration
public virtual float Predict(InputArray samples, OutputArray results = null, StatModel.Flags flags = (StatModel.Flags)0)
Parameters
Type | Name | Description |
---|---|---|
InputArray | samples | The input samples, floating-point matrix |
OutputArray | results | The optional output matrix of results. |
StatModel.Flags | flags | The optional flags, model-dependent. |
Returns
Type | Description |
---|---|
System.Single |
Train(InputArray, SampleTypes, InputArray)
Trains the statistical model
Declaration
public virtual bool Train(InputArray samples, SampleTypes layout, InputArray responses)
Parameters
Type | Name | Description |
---|---|---|
InputArray | samples | training samples |
SampleTypes | layout | SampleTypes value |
InputArray | responses | vector of responses associated with the training samples. |
Returns
Type | Description |
---|---|
System.Boolean |
Train(TrainData, Int32)
Trains the statistical model
Declaration
public virtual bool Train(TrainData trainData, int flags = 0)
Parameters
Type | Name | Description |
---|---|---|
TrainData | trainData | training data that can be loaded from file using TrainData::loadFromCSV or created with TrainData::create. |
System.Int32 | 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). |
Returns
Type | Description |
---|---|
System.Boolean |