Discussion of article "Data Science and Machine Learning (Part 09) : The K-Nearest Neighbors Algorithm (KNN)"

 

New article Data Science and Machine Learning (Part 09) : The K-Nearest Neighbors Algorithm (KNN) has been published:

This is a lazy algorithm that doesn't learn from the training dataset, it stores the dataset instead and acts immediately when it's given a new sample. As simple as it is, it is used in a variety of real-world applications

K-Nearest Neighbors Algorithm is a non-parametric supervised learning classifier that uses proximity to make classifications or predictions about the grouping of an individual data point. While this algorithm is mostly used for classification problems, It can be used for solving a regression problem too, It is often used as a classification algorithm due to its assumption that similar points in the dataset can be found near one another; k-nearest neighbors algorithm is one of the simplest algorithms in supervised machine learning. We will build our algorithm in this article as a classifier.


kNN algorithm

Image source: skicit-learn.org

Few Things to Note:

  1.  It is often used as a classifier but can be used for regression too.
  2.  K-NN is  a non-parametric algorithm, which means it does not make any assumption on the underlying data.
  3.  It is often called a lazy learner algorithm because it does not learn from the training set, Instead, it stores the data and uses it during the time of action
  4.  The KNN algorithm assumes the similarity between the new data and the available dataset and put the new data into the category that is most similar to the available categories.

Author: Omega J Msigwa

 
Greetings!

Sorry if I'm wrong with my assumption, but I think, that
void CKNNNearestNeighbors::VectorRemoveIndex(vector &v, ulong index)
 {
   vector new_v(v.Size()-1);
   
   for (ulong i=0, count = 0; i<v.Size(); i++)
      if (i == index)
        {
          new_v[count] = new_v[i];
          count++;
        }
 }
is useless. Code is taken in KNN_neareast_neighbors.mqh file.
I think it should remove vector element with specific index, but it removes nothing, because nothing happens with original vector and function returns nothing.

Am I wrong?