Click or drag to resize

KNearest Class

K nearest neighbors classifier
Inheritance Hierarchy

Namespace:  OpenCvSharp.ML
Assembly:  OpenCvSharp (in OpenCvSharp.dll) Version: 1.0.0
Syntax
public class KNearest : StatModel

The KNearest type exposes the following members.

Constructors
  NameDescription
Protected methodKNearest
Creates instance by raw pointer cv::ml::KNearest*
Top
Properties
  NameDescription
Public propertyAlgorithmType
Algorithm type, one of KNearest::Types.
Protected propertyAllocatedMemory
Gets or sets a memory address allocated by AllocMemory.
(Inherited from DisposableObject.)
Protected propertyAllocatedMemorySize
Gets or sets the byte length of the allocated memory
(Inherited from DisposableObject.)
Public propertyCvPtr
Native pointer of OpenCV structure
(Inherited from DisposableCvObject.)
Protected propertyDataHandle
Gets or sets a handle which allocates using cvSetData.
(Inherited from DisposableObject.)
Public propertyDefaultK
Default number of neighbors to use in predict method.
Public propertyEmax
Parameter for KDTree implementation
Public propertyEmpty
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
(Inherited from Algorithm.)
Public propertyIsClassifier
Whether classification or regression model should be trained.
Public propertyIsDisposed
Gets a value indicating whether this instance has been disposed.
(Inherited from DisposableObject.)
Public propertyIsEnabledDispose
Gets or sets a value indicating whether you permit disposing this instance.
(Inherited from DisposableObject.)
Top
Methods
  NameDescription
Protected methodAllocGCHandle
Pins the object to be allocated by cvSetData.
(Inherited from DisposableObject.)
Protected methodAllocMemory
Allocates the specified size of memory.
(Inherited from DisposableObject.)
Public methodCalcError
Computes error on the training or test dataset
(Inherited from StatModel.)
Public methodStatic memberCreate
Creates the empty model
Public methodDispose
Releases the resources
(Inherited from DisposableObject.)
Protected methodDispose(Boolean)
Releases the resources
(Inherited from DisposableObject.)
Protected methodDisposeManaged
Releases managed resources
(Overrides DisposableObjectDisposeManaged.)
Protected methodDisposeUnmanaged
releases unmanaged resources
(Inherited from DisposableCvObject.)
Public methodEmpty
(Inherited from StatModel.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Destructor
(Inherited from DisposableObject.)
Public methodFindNearest
Finds the neighbors and predicts responses for input vectors.
Public methodGetDefaultName
Returns the algorithm string identifier. This string is used as top level xml/yml node tag when the object is saved to a file or string.
(Inherited from Algorithm.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetVarCount
Returns the number of variables in training samples
(Inherited from StatModel.)
Public methodIsClassifier
Returns true if the model is classifier
(Inherited from StatModel.)
Public methodIsTrained
Returns true if the model is trained
(Inherited from StatModel.)
Public methodStatic memberLoad
Loads and creates a serialized model from a file.
Public methodStatic memberLoadFromString
Loads algorithm from a String.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodNotifyMemoryPressure
Notifies the allocated size of memory.
(Inherited from DisposableObject.)
Public methodPredict
Predicts response(s) for the provided sample(s)
(Inherited from StatModel.)
Public methodRead
Reads algorithm parameters from a file storage
(Inherited from Algorithm.)
Public methodSave
Saves the algorithm to a file. In order to make this method work, the derived class must implement Algorithm::write(FileStorage fs).
(Inherited from Algorithm.)
Public methodThrowIfDisposed
If this object is disposed, then ObjectDisposedException is thrown.
(Inherited from DisposableObject.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTrain(TrainData, Int32)
Trains the statistical model
(Inherited from StatModel.)
Public methodTrain(InputArray, SampleTypes, InputArray)
Trains the statistical model
(Inherited from StatModel.)
Public methodWrite
Stores algorithm parameters in a file storage
(Inherited from Algorithm.)
Top
Fields
  NameDescription
Protected fieldptr
Data pointer
(Inherited from DisposableCvObject.)
Top
See Also