100% found this document useful (1 vote)
101 views

K Nearest Neighbors

The document discusses the K-Nearest Neighbors algorithm, including its advantages such as being easy to implement and understand and not making assumptions, as well as its disadvantages like high computational costs, choice of parameters, and struggling with imbalanced classes. Real-world examples of using KNN for credit card fraud detection are also provided.

Uploaded by

r9492046
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
101 views

K Nearest Neighbors

The document discusses the K-Nearest Neighbors algorithm, including its advantages such as being easy to implement and understand and not making assumptions, as well as its disadvantages like high computational costs, choice of parameters, and struggling with imbalanced classes. Real-world examples of using KNN for credit card fraud detection are also provided.

Uploaded by

r9492046
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

K-Nearest Neighbors

K-Nearest Neighbors
• The k-nearest neighbors (KNN) algorithm is a non-parametric,
supervised learning classifier, which uses proximity to make
classifications or predictions about the grouping of an individual
data point. It is one of the popular and simplest classification and
regression classifiers used in machine learning today.
Why Use K-Nearest
Neighbors
The KNN algorithm can compete with the most accurate models
because it makes highly accurate predictions. Therefore, you can
use the KNN algorithm for applications that require high accuracy but
that do not require a human-readable model. The quality of the
predictions depends on the distance measure.
Advantage K-Nearest
Neighbors
1: Easy to implement and understand
One of the main benefits of KNN is that it is very easy to
implement and understand. You do not need to learn any complex
mathematical formulas or optimization techniques to use KNN.

2: Lazy learning and no assumptions


Another advantage of KNN is that it is a lazy learning algorithm,
meaning that it does not build any explicit model or generalize from the
training data.
Disadvantages K-Nearest
Neighbors
1: High memory and computational cost
One of the main drawbacks of KNN is that it requires a lot of memory and
computational resources to store and process the entire training data.

2: Choice of k and distance metric


Another challenge of using KNN is that it depends on the choice of k and the distance metric.
Both of these parameters can have a significant impact on the performance and accuracy of
KNN.

3: Imbalanced classes and missing values


A final limitation of KNN is that it can struggle with imbalanced classes and missing values in
the data. Imbalanced classes occur when some classes have much more instances than others,
which can cause KNN to be biased towards the majority class and ignore the minority class.
Real World Example of K-
Nearest Neighbors
K-nearest neighbor is also used in retail to detect patterns in credit

card usage. Many new transaction-scrutinizing software

applications use KNN algorithms to analyze register data and spot

unusual patterns that indicate suspicious activity.


Algorithm Execution of K-
Nearest Neighbors
The K-NN working can be explained on the basis of the below algorithm:

• Step-1: Select the number K of the neighbors


• Step-2: Calculate the Euclidean distance of K number of neighbors
• Step-3: Take the K nearest neighbors as per the calculated Euclidean
distance.
• Step-4: Among these k neighbors, count the number of the data points in
each category.
• Step-5: Assign the new data points to that category for which the number of
the neighbor is maximum.
• Step-6: Our model is ready.
Thank you!!
Members:

Nepa, Christian mark


Olmedo, Dulce Amor
Raman, John Philip
Tagpuno, Mhel Angelo
Tan, Crystel

You might also like