For each input vector (which are rows of the matrix samples) the method finds k <= get_max_k() nearest neighbor. In case of regression, the predicted result will be a mean value of the particular vector's neighbor responses. In case of classification the class is determined by voting.

Namespace: Emgu.CV.ML
Assembly: Emgu.CV.ML (in Emgu.CV.ML.dll) Version: 2.2.1.1150 (2.2.1.1150)

Syntax

         
 C#  Visual Basic  Visual C++ 
public static float CvKNearestFindNearest(
	IntPtr classifier,
	IntPtr samples,
	int k,
	IntPtr results,
	IntPtr[] kNearestNeighbors,
	IntPtr neighborResponses,
	IntPtr dist
)
Public Shared Function CvKNearestFindNearest ( _
	classifier As IntPtr, _
	samples As IntPtr, _
	k As Integer, _
	results As IntPtr, _
	kNearestNeighbors As IntPtr(), _
	neighborResponses As IntPtr, _
	dist As IntPtr _
) As Single
public:
static float CvKNearestFindNearest(
	IntPtr classifier, 
	IntPtr samples, 
	int k, 
	IntPtr results, 
	array<IntPtr>^ kNearestNeighbors, 
	IntPtr neighborResponses, 
	IntPtr dist
)

Parameters

classifier
IntPtr
The KNearest classifier
samples
IntPtr
The sample matrix where each row is a sample
k
Int32
The number of nearest neighbor to find
results
IntPtr
Can be IntPtr.Zero if not needed. If regression, return a mean value of the particular vector's neighbor responses; If classification, return the class determined by voting.
kNearestNeighbors
array<IntPtr>[]()[][]
Should be IntPtr.Zero if not needed. Setting it to non-null values incures a performance panalty. A matrix of (k * samples.Rows) rows and (samples.Cols) columns that will be filled the data of the K nearest-neighbor for each sample
neighborResponses
IntPtr
Should be IntPtr.Zero if not needed. The response of the neighbors. A vector of k*_samples->rows elements.
dist
IntPtr
Should be IntPtr.Zero if not needed. The distances from the input vectors to the neighbors. A vector of k*_samples->rows elements.

Return Value

In case of regression, the predicted result will be a mean value of the particular vector's neighbor responses. In case of classification the class is determined by voting

See Also