Show / Hide Table of Contents

Class StatModel

Base class for statistical models in ML

Inheritance
System.Object
DisposableObject
DisposableCvObject
Algorithm
StatModel
ANN_MLP
DTrees
KNearest
LogisticRegression
NormalBayesClassifier
SVM
Implements
ICvPtrHolder
Inherited Members
Algorithm.Write(FileStorage)
Algorithm.Read(FileNode)
Algorithm.Save(String)
Algorithm.GetDefaultName()
DisposableCvObject.ptr
DisposableCvObject.DisposeUnmanaged()
DisposableCvObject.CvPtr
DisposableObject.DataHandle
DisposableObject.IsDisposed
DisposableObject.IsEnabledDispose
DisposableObject.AllocatedMemory
DisposableObject.AllocatedMemorySize
DisposableObject.Dispose()
DisposableObject.Dispose(Boolean)
DisposableObject.DisposeManaged()
DisposableObject.AllocGCHandle(Object)
DisposableObject.AllocMemory(Int32)
DisposableObject.NotifyMemoryPressure(Int64)
DisposableObject.ThrowIfDisposed()
Namespace: OpenCvSharp.ML
Assembly: OpenCvSharp.dll
Syntax
public abstract class StatModel : Algorithm, ICvPtrHolder

Methods

| Improve this Doc View Source

CalcError(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
| Improve this Doc View Source

Empty()

Declaration
public virtual bool Empty()
Returns
Type Description
System.Boolean
| Improve this Doc View Source

GetVarCount()

Returns the number of variables in training samples

Declaration
public virtual int GetVarCount()
Returns
Type Description
System.Int32
| Improve this Doc View Source

IsClassifier()

Returns true if the model is classifier

Declaration
public virtual bool IsClassifier()
Returns
Type Description
System.Boolean
| Improve this Doc View Source

IsTrained()

Returns true if the model is trained

Declaration
public virtual bool IsTrained()
Returns
Type Description
System.Boolean
| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

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

Implements

ICvPtrHolder
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX