SlideShare a Scribd company logo
Dr. Dalal AL-Alimi
• K-Nearest Neighbors
• Classification and Regression Trees
• K-nearest neighbors (KNN) is considered a “lazy learner,” as there is no learning
required in the model.
• For a new data point, predictions are made by searching through the entire training
set for the K most similar instances (the neighbors) and summarizing the output
variable for those K instances.
• To determine which of the K instances in the training dataset are most similar to a
new input, a distance measure is used.
• The most popular distance measure is Euclidean distance, which is calculated
as the square root of the sum of the squared differences between a point a and
a point b across all input attributes i, and which is represented as 𝑑 𝑎, 𝑏
= σ𝑖=1
𝑛
(𝑎𝑖−𝑏𝑖)2 .
• Euclidean distance is a good distance measure to use if the input variables are
similar in type.
Advantages of KNN:
1. No Training Required – No learning phase, making it easy to use.
2. Handles New Data Well – New data can be added without affecting accuracy.
3. Easy to Understand – Intuitive and simple to implement.
4. Supports Multiclass Classification – Naturally handles multiple classes.
5. Can Learn Complex Decision Boundaries – Adapts well to different patterns.
6. Effective with Large Datasets – Performs well when enough data is available.
7. Robust to Noise – Can handle noisy data without filtering outliers.
Disadvantages of KNN:
1. Choosing a Distance Metric is Challenging – Hard to justify the best one.
2. Performs Poorly on High-Dimensional Data – Struggles when features are too
many.
3. Slow and Expensive for Predictions – Needs to compute distances for all
neighbors.
4. Sensitive to Noise – Can be affected by noisy data.
5. Requires Manual Handling of Missing Values and Outliers – Needs
preprocessing.
• Feature Scaling is Necessary – Standardization or normalization is
required to avoid incorrect predictions.
• The model can be represented by a binary
tree (or decision tree), where each node is
an input variable x with a split point and
each leaf contains an output variable y for
prediction.
• Figure shows an example of a simple
classification tree to predict whether a
person is a male or a female based on two
inputs of height (in centimeters) and weight
(in kilograms).
Introduction to Artificial Intelligence_ Lec 8
Advantages of CART (Classification and Regression Trees):
1. Easy to Interpret – Simple to understand and visualize.
2. Can Learn Complex Relationships – Captures non-linear patterns
effectively.
3. Minimal Data Preparation – Does not require scaling or extensive
preprocessing.
4. Built-in Feature Importance – Identifies important features naturally.
5. Performs Well on Large Datasets – Scales effectively with more data.
6. Supports Both Regression and Classification – Versatile for different tasks.
Disadvantages of CART:
1. Prone to Overfitting – Needs pruning to prevent excessive complexity.
2. Non-Robust to Small Changes – Slight variations in data can drastically
change the tree.
3. Sensitive to Noisy Data – Can easily pick up irrelevant patterns.
4. Greedy Algorithm – Makes local optimal decisions at each step, which may
not lead to a globally optimal tree.

More Related Content

PPTX
K-Nearest Neighbor Classifier
DOCX
Types of Machine Learnig Algorithms(CART, ID3)
PPTX
Reuqired ppt for machine learning algirthms and part
PDF
Lecture03 - K-Nearest-Neighbor Machine learning
PDF
Lecture 6 - Classification Classification
PPTX
knn is the k nearest algorithm ppt that includes all about knn, its adv and d...
PPTX
KNN CLASSIFIER, INTRODUCTION TO K-NEAREST NEIGHBOR ALGORITHM.pptx
K-Nearest Neighbor Classifier
Types of Machine Learnig Algorithms(CART, ID3)
Reuqired ppt for machine learning algirthms and part
Lecture03 - K-Nearest-Neighbor Machine learning
Lecture 6 - Classification Classification
knn is the k nearest algorithm ppt that includes all about knn, its adv and d...
KNN CLASSIFIER, INTRODUCTION TO K-NEAREST NEIGHBOR ALGORITHM.pptx

Similar to Introduction to Artificial Intelligence_ Lec 8 (20)

PPT
Lecture3 (3).ppt
PDF
Machine Learning Algorithm - KNN
PDF
Bank loan purchase modeling
PPTX
3a-knn.pptxhggmtdu0lphm0kultkkkkkkkkkkkk
PDF
K - Nearest neighbor ( KNN )
PDF
Di35605610
PPT
KNN&DECISION TREE in machine learning and pattern
PPTX
K Nearest Neighbour (KNN) Alg.pptx fro machine learning
PPTX
KNN Classificationwithexplanation and examples.pptx
PDF
Natural Language Processing of applications.pdf
PDF
Enhancing Classification Accuracy of K-Nearest Neighbors Algorithm using Gain...
PDF
Introduction to machine learning
PPT
instance bases k nearest neighbor algorithm.ppt
PPTX
K Nearest Neighbor Algorithm
PPTX
Knn 160904075605-converted
PDF
Machine learning in science and industry — day 1
PDF
k-nearest neighbour Machine Learning.pdf
PPTX
NEAREST NEIGHBOUR CLUSTER ANALYSIS.pptx
PPTX
k-Nearest Neighbors with brief explanation.pptx
Lecture3 (3).ppt
Machine Learning Algorithm - KNN
Bank loan purchase modeling
3a-knn.pptxhggmtdu0lphm0kultkkkkkkkkkkkk
K - Nearest neighbor ( KNN )
Di35605610
KNN&DECISION TREE in machine learning and pattern
K Nearest Neighbour (KNN) Alg.pptx fro machine learning
KNN Classificationwithexplanation and examples.pptx
Natural Language Processing of applications.pdf
Enhancing Classification Accuracy of K-Nearest Neighbors Algorithm using Gain...
Introduction to machine learning
instance bases k nearest neighbor algorithm.ppt
K Nearest Neighbor Algorithm
Knn 160904075605-converted
Machine learning in science and industry — day 1
k-nearest neighbour Machine Learning.pdf
NEAREST NEIGHBOUR CLUSTER ANALYSIS.pptx
k-Nearest Neighbors with brief explanation.pptx
Ad

More from Dalal2Ali (9)

PDF
Introduction to Artificial Intelligence_Lec 1
PDF
Introduction to Artificial Intelligence_ Lec 4
PDF
Introduction to Artificial Intelligence_ Lec 2
PDF
Introduction to Artificial Intelligence_ Lec 9
PDF
Introduction to Artificial Intelligence_ Lec 10
PDF
Introduction to Artificial Intelligence_ Lec 6
PDF
Introduction to Artificial Intelligence_ Lec 7
PDF
Introduction to Artificial Intelligence_ Lec 3
PDF
Introduction to Artificial Intelligence_ Lec 5
Introduction to Artificial Intelligence_Lec 1
Introduction to Artificial Intelligence_ Lec 4
Introduction to Artificial Intelligence_ Lec 2
Introduction to Artificial Intelligence_ Lec 9
Introduction to Artificial Intelligence_ Lec 10
Introduction to Artificial Intelligence_ Lec 6
Introduction to Artificial Intelligence_ Lec 7
Introduction to Artificial Intelligence_ Lec 3
Introduction to Artificial Intelligence_ Lec 5
Ad

Recently uploaded (20)

PDF
Introduction to the R Programming Language
PDF
Fluorescence-microscope_Botany_detailed content
PDF
Introduction to Data Science and Data Analysis
PDF
Business Analytics and business intelligence.pdf
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PPTX
SAP 2 completion done . PRESENTATION.pptx
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PPTX
Computer network topology notes for revision
PPTX
Database Infoormation System (DBIS).pptx
PDF
.pdf is not working space design for the following data for the following dat...
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPTX
Supervised vs unsupervised machine learning algorithms
PDF
Lecture1 pattern recognition............
PDF
Mega Projects Data Mega Projects Data
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PPT
Quality review (1)_presentation of this 21
PPTX
Qualitative Qantitative and Mixed Methods.pptx
Introduction to the R Programming Language
Fluorescence-microscope_Botany_detailed content
Introduction to Data Science and Data Analysis
Business Analytics and business intelligence.pdf
IBA_Chapter_11_Slides_Final_Accessible.pptx
Clinical guidelines as a resource for EBP(1).pdf
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
SAP 2 completion done . PRESENTATION.pptx
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
Computer network topology notes for revision
Database Infoormation System (DBIS).pptx
.pdf is not working space design for the following data for the following dat...
Introduction-to-Cloud-ComputingFinal.pptx
Supervised vs unsupervised machine learning algorithms
Lecture1 pattern recognition............
Mega Projects Data Mega Projects Data
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
Quality review (1)_presentation of this 21
Qualitative Qantitative and Mixed Methods.pptx

Introduction to Artificial Intelligence_ Lec 8

  • 2. • K-Nearest Neighbors • Classification and Regression Trees
  • 3. • K-nearest neighbors (KNN) is considered a “lazy learner,” as there is no learning required in the model. • For a new data point, predictions are made by searching through the entire training set for the K most similar instances (the neighbors) and summarizing the output variable for those K instances. • To determine which of the K instances in the training dataset are most similar to a new input, a distance measure is used.
  • 4. • The most popular distance measure is Euclidean distance, which is calculated as the square root of the sum of the squared differences between a point a and a point b across all input attributes i, and which is represented as 𝑑 𝑎, 𝑏 = σ𝑖=1 𝑛 (𝑎𝑖−𝑏𝑖)2 . • Euclidean distance is a good distance measure to use if the input variables are similar in type.
  • 5. Advantages of KNN: 1. No Training Required – No learning phase, making it easy to use. 2. Handles New Data Well – New data can be added without affecting accuracy. 3. Easy to Understand – Intuitive and simple to implement. 4. Supports Multiclass Classification – Naturally handles multiple classes. 5. Can Learn Complex Decision Boundaries – Adapts well to different patterns. 6. Effective with Large Datasets – Performs well when enough data is available. 7. Robust to Noise – Can handle noisy data without filtering outliers.
  • 6. Disadvantages of KNN: 1. Choosing a Distance Metric is Challenging – Hard to justify the best one. 2. Performs Poorly on High-Dimensional Data – Struggles when features are too many. 3. Slow and Expensive for Predictions – Needs to compute distances for all neighbors. 4. Sensitive to Noise – Can be affected by noisy data. 5. Requires Manual Handling of Missing Values and Outliers – Needs preprocessing. • Feature Scaling is Necessary – Standardization or normalization is required to avoid incorrect predictions.
  • 7. • The model can be represented by a binary tree (or decision tree), where each node is an input variable x with a split point and each leaf contains an output variable y for prediction. • Figure shows an example of a simple classification tree to predict whether a person is a male or a female based on two inputs of height (in centimeters) and weight (in kilograms).
  • 9. Advantages of CART (Classification and Regression Trees): 1. Easy to Interpret – Simple to understand and visualize. 2. Can Learn Complex Relationships – Captures non-linear patterns effectively. 3. Minimal Data Preparation – Does not require scaling or extensive preprocessing. 4. Built-in Feature Importance – Identifies important features naturally. 5. Performs Well on Large Datasets – Scales effectively with more data. 6. Supports Both Regression and Classification – Versatile for different tasks.
  • 10. Disadvantages of CART: 1. Prone to Overfitting – Needs pruning to prevent excessive complexity. 2. Non-Robust to Small Changes – Slight variations in data can drastically change the tree. 3. Sensitive to Noisy Data – Can easily pick up irrelevant patterns. 4. Greedy Algorithm – Makes local optimal decisions at each step, which may not lead to a globally optimal tree.