K-NN Numerical N Theory
K-NN Numerical N Theory
CHAPTER
Instance-Based Learning
(IBL)
12.1 INTRODUCTION
The instance-based learning is
classification and regression
asupervised learning technique
tasks. The instance-based which is used for
after conparing the current learning
ealled as "Lazy Learning" or instances (examples) with the previous performs operation
"Memory-based
next step is taken only after the Learning". Because, in
instances. It is als0
this technigue the
next instance is arrived.
12.1.1 Types of Instance-based
1. K-nearest Learning Methods
Neighbourhood (K-NN) Algorithm
2. Locally Weighted
3. Radial Basis Regression Algorithm
Function Network
4. Case-based Learning
5. Learning Vector
6. Self Quantization (LVQ)
Organising Map (SOM)
Approaches for Instance Based Learning
1. K-NN
2. Locally Weighted 3. Radial Basis
Regression (LWR) Function (RBF)
4. Case Based
Learning (CBL)
5. Learning Vector
Quantization (LVQ)
6. Self Organising
Map (SOM)
Fig. 12.1. Types of instance-based
learning methods
EARNING
12.2 K-NEAREST NEIGHBOUR (K-NN) ALGORITHM
Category B Category B
Prample 12.1. Let us consider Fig. 12.4. in which we have a new data point. Our task
is toput it in the required category (class) as class A or class B.
Category B
Category A
AB(X, Y)
TAX, Y,)
X
X,
2. 20 80 5
3 50 100
:
.
Example 12.2. The result marks of five students are given in Table 12.2. Now, a te
query is arrived about a student (X) as student (X) marks.
Table 12.2. Training Data (Student's marks)
S.No. Math (X) Science (Y) Result
1. Fail
2. 6 7 Pass
3. 7 Pass
4. 5 5 Fail
5. 8 Pass
Math 6
Test Data
Science 8
Now, our task is to tell whether this new student (X) is pass or fail.
(NSTANCE-BASED LEARNING (IBL) 243
NG
Solution.
Row 3 1
Row 5 2 Increasing order
Row 4 3.16
Row 1 5.38
Step 4. Now pick top 3rows of Euclidean Table 12.3 and check. All
rows 2, 3, 5 belong to category "Pass". So we decide that the new
these points of
student (X)
is a "pass" category student. Hence, classification task is done.
Example 12.3. Python Program Implimentation of K-NN Algorithm (KNN as
an Classifier algorithmn)
"First, start with importing necessary python packages:
1. import numpy as np
2. import matplotlib.pyplot as plt
3. import pandas as pd