February 27, 2023

8 kNN Model

1 Similarity Based Learning

image-20230307135237509

Compute the distance matrices between objects

image-20230307135320379

2 k Nearest Neighbor (kNN) Model

2.1 Pros and Cons of kNN

Pros Cons
Simple and Effective Does not produce a model, limiting the ability to understand how the features are related to the class
Makes no assumption about the underlying data distribution
Non-parametric
Requires selection of an appropriate value of ‘k’

2.2 Example

image-20230307135514058

image-20230307135528439

image-20230307135551335

image-20230307135600672

image-20230307135654082

image-20230307135706642

3 kNN Model Assessment

image-20230307135731080

image-20230307135744961

4 Data Normalization: Standardization & Scaling

Suppose we have 2 data items

If we use both the variables in a model

Solution

4.1 Data Standardization and Scaling

image-20230307135919181

5 kNN in Python

03_kNN_Optimum_k_Iris_Sci_L_ConMat.ipynb

# DS# Data Mining