NEAREST_NEIGHBOR_CVIP

nearest_neighbor_cvip() - reads test and training files of feature vectors and creates output file for classification using nearest neighbor classification method.

Contents

SYNTAX

nearest_neighbor_cvip(file_tt, file_tr, file_out, option_normalize, option_distance, [s_min], [s_max], [r_softmax], [r_minkowski])

Input Parameters include :

   0 – No Normalization
   1 – Range-normalize
   2 – Unit Vector normalization
   3 – Standard Normal Density normalization
   4 – Min-max normalization     ----> s_min, s_max
   5 – Softmax scaling           ----> r_softmax
   1 – Euclidean Distance
   2 – City block or Absolute value metric
   3 – Maximum value metric
   4 – Minkowski distance        ----> r_minkowski
   5 – Vector inner product
   6 – Tanimoto metric
If option_normalize is either 4 or 5, or option_distance is 4, then their
corresponding parameters should be given as input arguments seperated
by comma after option_distance. Look at the below examples:

DESCRIPTION

Given the training and test set with the desired methods for normalization and distance, This function classifies the vectors in the test set with Nearest Neighbor (NN) method. Depending on the normalization method and the distance used, the number of input arguments vary.

The accepted values for normalization and distance are as follows. Also the extra input arguments for the corresponding method is shown by arrows (----->).

REFERENCE

1. Scott E Umbaugh. DIGITAL IMAGE PROCESSING AND ANALYSIS: Applications with MATLAB and CVIPtools, 3rd Edition.

EXAMPLE 1

                  file_tt = 'myTestVectors.CSV';
                  file_tr = 'myTrainingVectors.CSV';
                  file_out = 'ClassifiedTestVectors.CSV';
                  option_normalize = 4;
                  option_distance = 6;
                  s_min = 0; s_max = 1;
                  nearest_neighbor_cvip(file_tt, file_tr, file_out, option_normalize, option_distance, s_min, s_max)

EXAMPLE 2

                  file_tt = 'myTestVectors.CSV';
                  file_tr = 'myTrainingVectors.CSV';
                  file_out = 'ClassifiedTestVectors.CSV';
                  option_normalize = 4;
                  option_distance = 4;
                  s_min = 0; s_max = 1;
                  r_minkowski = 3;
                  nearest_neighbor_cvip(file_tt, file_tr, file_out, option_normalize, option_distance, s_min, s_max, r_minkowski)

EXAMPLE 3

                  file_tt = 'myTestVectors.CSV';
                  file_tr = 'myTrainingVectors.CSV';
                  file_out = 'ClassifiedTestVectors.CSV';
                  option_normalize = 5;
                  option_distance = 4;
                  r_softmax = 5;
                  r_minkowski = 3;
                  nearest_neighbor_cvip(file_tt, file_tr, file_out, option_normalize, option_distance, r_softmax, r_minkowski)

CREDITS

Author: Mehrdad Alvandipour, March 2017
Copyright © 2017-2018 Scott E Umbaugh
For updates visit CVIP Toolbox Website