<< initialize_parameters Neural_Network_Functions model_forward >>

NeuralNet >> Neural_Network_Functions > knn

knn

K Nearest neighbours classification

Parameters

x :

Input data, in m x n matrix, where m is the features, n is different datasets

y :

Target data, in 1 x n vector, where the value shall be the classes which correspond to each set of data in x

xtest :

Data undertest, in m x p, where m must be the same number of features, p is any set of data to be tested.

k :

Number of neighbours to be compare

pred :

Predicted class for xtest

dd :

Distance of the xtests to each classes

Description

K Nearest neighbours classification

Examples

P = [1 2 3 4; 1 2 3 4];
T = [1 2 3 4];
[pred,dd] = knn(P, T, [1.2 ; 1.2], 1);
disp("Predicted Class : " + string(pred));
disp("Distance from Class " + string([1:4]') + " : "  + string(dd));

See also

Authors


Report an issue
<< initialize_parameters Neural_Network_Functions model_forward >>