The algorithm is the basic for everything nearest neighbour is used for machine learning .These is used find the pattern by Nearest neighbour ones.This is supervised type of learning
2. Slides Fill with
• What is meant by algorithm
• Algorithm in Machine learning
• Category of NN algorithm
• Nearest neighbour
• How its work?
• Pseudo code
• Code-Explanation
• Example
• Positive and negative
3. What is meant by algorithm
COMPUTER
INPUT OUTPUT
PROBLEM
ALGORITHM
4. ALGORITHM
• It is a step-by-step procedure to solve a
problem
• Algorithm provides an overview for
solving and implementing problem
• These algorithm decides the solution of
the problem by implementing in
procedural way
6. ALGORITHM IN MACHINE LEARNING
• IN the machine learning algorithm is
categorized based on types of machine
learning
• Types of machine learning are
Supervised machine learning
Unsupervised machine learning
Reinforcement machine learning.
7. A computer is learn from past experience to do some task
and measure performance then predict future.
Many machine learning tasks can be solved &
implemented by using some Algorithms.
8. Category of K-NN algorithm
Nearest neighbour is the kind of
supervised learning
These follow the instance based learning
approach
INSTANCE BASED LEARNING
The instance based stored presented training data in the
memory ,when new instance is arrived a set of related instance
is retrieved from memory and classified for new instance.
Instance based is used for more complex and symbolic data.
9. Nearest neighbour
Nearest neighbour is conceptually
straightforward approaches to
approximating real-valued or discrete-
valued target functions.
Instances are represented in this
fashion and the process for identifying
"neighbour ing" instances is elaborated
accordingly
10. How its work
1. Determine parameter value K
2. Calculate the distance between the
query instance and training data
3. Sort the distance
4. Determine the nearest neighbour based
kth distance.
5. Gather the category of the nearest
instances according to k value
6. Predict the result by using simple
majority instances
13. Code explanation
• Training algorithm:
f-Data
f(x)-instance or pattern Example data
• Classification algorithm:
xq -query instance
xl . . .xk -k instances which nearest to xq.
The value should return if the given value is correct.
14. Code explanation
Here we have to compare
each instance with new
instance which is nearest
instance
V-distance between new
instance and training data
argmax-Average max
distance between new and
comparing training data
i=1-initial value
K-k instances
v belongs to V-each data is
belongs to V
15. Code explanation
Here ,
If and b are comparing
means it a and b is equals
then pattern matches with
training and new instances
and returns 1.
Otherwise 0 and not
matching
16. Example
ACID DURABILITY STRENGHT CLASSIFICATION
7 7 Bad
7 4 Good
3 4 Good
1 4 Good
3 7 ?
To find: Guess the classification of the new
instance with x=3
17. Example
• Given:
Step 1: Find the K=3
Step 2:Calculate the each instance
distance with new instance
(7-3)2+(7-7)2 = 4
(7-3)2+(7-4)2= 5
19. Example
• Step 3:Sort the calculated distance in
ascending order
The order is
1. 5
2. 4
3. 3
4. 0
5. 13
20. Example
• Step4:Pick neighbour ones with k=3 so,
take first three instance 5,4 and 3
• Step 5 :find the category of the instances
5-Good
4-Bad
3-Good
• Step6:Choose majority value as a result
• The result of new instance is Good
21. Positive of nearest neighbour
Simple to implement
Easy to understand
simple Algorithm
K-NN classification is best for local
information
The result can be able to classify easily
22. Negative of nearest neighbour
These cause over-fitting
Robust is noisy
Classify the new instance cost is high
Training data should be provided for
classification