SlideShare une entreprise Scribd logo
1  sur  34
 Classification is done by relating the unknown to the known according to some
distance/similarity function
 Stores all available cases and classifies new cases based on similarity measure
 Different names
 Memory-based reasoning
 Example-based reasoning
 Instance-based reasoning
 Case-based reasoning
 Lazy learning
 kNN determines the decision boundary locally. Ex. for 1NN we assign each
document to the class of its closest neighbor
 For kNN we assign each document to the majority class of its closest neighbors
where k is a parameter
 The rationale of kNN classification is based on contiguity hypothesis, we expect
the test document to have the same training label as the training documents
located in the local region surrounding the document.
 Veronoi tessellation of a set of objects decomposes space into Voronoi cells, where
each object’s cell consist of all points that are closer to the object than to other
objects.
 It partitions the plane to complex polygons, each containing its corresponding
document.
Let k=3
P(circle class | star) = 1/3
P(X class | star) = 2/3
P(diamond class | star) = 0
3NN estimate is –
P(circle class | star) = 1/3
1NN estimate is –
P(circle class | star) = 1
3NN preferring X class and 1NN
preferring circle class
 Advantages
 Non-parametric architecture
 Simple
 Powerful
 Requires no training time
 Disadvantages
 Memory intensive
 Classification/estimation is slow
 The distance is calculated using Euclidean distance
2
21
2
21 )()( yyxxD 
MinMax
MinX
Xs



2
21
2
21 )()( yyxxD 
MinMax
MinX
Xs



 If k=1, select the nearest neighbors
 If k>1
 For classification, select the most frequent neighbors
 For regression, calculate the average of k neighbors
 An inductive learning task – use particular facts to make more generalized
conclusions
 Predictive model based on branching series of Boolean test – these Boolean test
are less complex than the one-stage classifier
 Its learning from class labeled tuples
 Can be used as visual aid to structure and solve sequential problems
 Internal node (Non-leaf node) denotes a test on an attribute, each branch
represents an outcome of the test and each leaf node holds a class label
If we leave at 10
AM and there are
no cars stalled on
the road, what will
our commute time
be?
Leave At
Stall? Accident?
10 AM 9 AM
8 AM
Long
Long
Short Medium Long
No Yes No Yes
 In this decision tree, we made a series of Boolean decision and followed a
corresponding branch –
 Did we leave at 10AM?
 Did the car stall on road?
 Is there an accident on the road?
 By answering each of these questions as yes or no, we can come to a conclusion on
how long our commute might take
 We do not have to represent this tree graphically
 We can represent this as a set of rules. However, it may be harder to read
if hour == 8am
commute time = long
else if hour == 9am
if accident == yes
commute time = long
else
commute time = medium
else if hour == 10am
if stall == yes
commute time = long
else
commute time = short
 The algorithm is called with three parameters – data partition, attribute list,
attribute subset selection.
 It’s a set of tuples and there associated class label
 Attribute list is a list of attributes describing the tuples
 Attribute selection method specifies a heuristic procedure for selecting attribute that
best discriminates the tuples
 Tree starts at node N. if all the tuples in D are of the same class, then node N
becomes a leaf and is labelled with that class
 Else attribute selection method is used to determine the splitting criteria.
 Node N is labelled with splitting criteria, which serves as a test at the node.
 The previous experience decision table showed 4 attributes – hour, weather,
accident and stall
 But the decision tree showed three attributes – hour, attribute and stall
 So which attribute is to be kept and which is to be removed?
 Methods for selecting attribute shows that weather is not a discriminating
attribute
 Method – given a number of competing hypothesis, the simplest one is preferable
 We will focus on ID3 algorithm
 Basic idea
 Choose the best attribute to split the remaining instances and make that attribute a
decision node
 Repeat this process for recursively for each child
 Stop when
 All attribute have same target attribute value
 There are no more attributes
 There are no more instances
 ID3 splits attributes based on their entropy.
 Entropy is a measure of disinformation
 Entropy is minimized when all values of target attribute are the same
 If we know that the commute time will be short, the entropy=0
 Entropy is maximized when there is an equal chance of values for the target
attribute (i.e. result is random)
 If commute time = short in 3 instances, medium in 3 instances and long in 3 instances,
entropy is maximized
 Calculation of entropy
 Entropy S = ∑(i=1 to l)-|Si|/|S| * log2(|Si|/|S|)
 S = set of examples
 Si = subset of S with value vi under the target attribute
 L – size of range of target attribute
 If we break down the leaving time to the minute, we might get something like this
 Since the entropy is very less for each branch and we have n branches with n
leaves. This would not be helpful for predictive modelling
 We use a technique called as discretization. We choose cut point such as 9AM for
splitting continuous attributes
8:02 AM 10:02 AM8:03 AM 9:09 AM9:05 AM 9:07 AM
Long Medium Short Long Long Short
 Consider the attribute commute time
 When we split the attribute, we increase the entropy so we don’t have a decision
tree with the same number of cut points as leaves
8:00 (L), 8:02 (L), 8:07 (M), 9:00 (S), 9:20 (S), 9:25 (S), 10:00 (S), 10:02 (M)
 Binary decision trees
 Classification of an input vector is done by traversing the tree beginning at the root node
and ending at the leaf
 Each node of the tree computes an inequality
 Each leaf is assigned to a particular class
 Input space is based on one input variable
 Each node draws a boundary that can be geometrically interpreted as a hyperplane
perpendicular to the axis
B C
Yes No
Yes No
NoYes
BMI<24
 They are similar to binary tree
 Inequality computed at each node takes on a linear form that may depend on
linear variable
aX1+bX2
Yes No
Yes No
NoYes
 Chi-squared automatic intersection detector(CHAID)
 Non-binary decision tree
 Decision made at each node is based on single variable, but can result in multiple
branches
 Continuous variables are grouped into a finite number of bins to create categories
 Equal population bins is created for CHAID
 Classification and Regression Trees (CART) are binary decision trees which split a
single variable at each node
 The CART algorithm goes through an exhaustive search of all variables and split values
to find the optimal splitting rule for each node.
 There is another technique for reducing the number of attributes used in tree –
pruning
 Two types of pruning
 Pre-pruning (forward pruning)
 Post-pruning (backward pruning)
 Pre-pruning
 We decide during the building process, when to stop adding attributes (possibly based on
their information gain)
 However, this may be problematic – why?
 Sometimes, attribute individually do not compute much to a decision, but combined they may
have significant impact.
 Post-pruning waits until full decision tree has been built and then prunes the
attributes.
 Two techniques:
 Subtree replacement
 Subtree raising
 Subtree replacement
A
B
C
1 2 3
4 5
 Node 6 replaced the subtree
 May increase accuracy
A
B
6 4 5
 Entire subtree is raised onto another node
A
B
C
1 2 3
4 5
A
C
1 2 3
 While decision tree classifies quickly, the time taken for building the tree may be
higher than any other type of classifier.
 Decision tree suffer from problem of error propagation throughout the tree
 Since decision trees work by a series of local decision, what happens if one of these
decision is wrong?
 Every decision from that point on may be wrong
 We may return to the correct path of the tree

Contenu connexe

Tendances

K means clustering
K means clusteringK means clustering
K means clusteringkeshav goyal
 
Decision Tree - C4.5&CART
Decision Tree - C4.5&CARTDecision Tree - C4.5&CART
Decision Tree - C4.5&CARTXueping Peng
 
Chapter 4 Classification
Chapter 4 ClassificationChapter 4 Classification
Chapter 4 ClassificationKhalid Elshafie
 
k Nearest Neighbor
k Nearest Neighbork Nearest Neighbor
k Nearest Neighborbutest
 
Data mining technique (decision tree)
Data mining technique (decision tree)Data mining technique (decision tree)
Data mining technique (decision tree)Shweta Ghate
 
KNN Algorithm - How KNN Algorithm Works With Example | Data Science For Begin...
KNN Algorithm - How KNN Algorithm Works With Example | Data Science For Begin...KNN Algorithm - How KNN Algorithm Works With Example | Data Science For Begin...
KNN Algorithm - How KNN Algorithm Works With Example | Data Science For Begin...Simplilearn
 
Decision Trees
Decision TreesDecision Trees
Decision TreesStudent
 
Decision trees in Machine Learning
Decision trees in Machine Learning Decision trees in Machine Learning
Decision trees in Machine Learning Mohammad Junaid Khan
 
Types of clustering and different types of clustering algorithms
Types of clustering and different types of clustering algorithmsTypes of clustering and different types of clustering algorithms
Types of clustering and different types of clustering algorithmsPrashanth Guntal
 
K-Nearest Neighbor Classifier
K-Nearest Neighbor ClassifierK-Nearest Neighbor Classifier
K-Nearest Neighbor ClassifierNeha Kulkarni
 
Introduction to Linear Discriminant Analysis
Introduction to Linear Discriminant AnalysisIntroduction to Linear Discriminant Analysis
Introduction to Linear Discriminant AnalysisJaclyn Kokx
 
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...Edureka!
 
Random Forest and KNN is fun
Random Forest and KNN is funRandom Forest and KNN is fun
Random Forest and KNN is funZhen Li
 
2.1 Data Mining-classification Basic concepts
2.1 Data Mining-classification Basic concepts2.1 Data Mining-classification Basic concepts
2.1 Data Mining-classification Basic conceptsKrish_ver2
 
3.3 hierarchical methods
3.3 hierarchical methods3.3 hierarchical methods
3.3 hierarchical methodsKrish_ver2
 

Tendances (20)

Decision tree
Decision treeDecision tree
Decision tree
 
K means clustering
K means clusteringK means clustering
K means clustering
 
Decision Tree - C4.5&CART
Decision Tree - C4.5&CARTDecision Tree - C4.5&CART
Decision Tree - C4.5&CART
 
Chapter 4 Classification
Chapter 4 ClassificationChapter 4 Classification
Chapter 4 Classification
 
K Nearest Neighbors
K Nearest NeighborsK Nearest Neighbors
K Nearest Neighbors
 
k Nearest Neighbor
k Nearest Neighbork Nearest Neighbor
k Nearest Neighbor
 
Data mining technique (decision tree)
Data mining technique (decision tree)Data mining technique (decision tree)
Data mining technique (decision tree)
 
KNN Algorithm - How KNN Algorithm Works With Example | Data Science For Begin...
KNN Algorithm - How KNN Algorithm Works With Example | Data Science For Begin...KNN Algorithm - How KNN Algorithm Works With Example | Data Science For Begin...
KNN Algorithm - How KNN Algorithm Works With Example | Data Science For Begin...
 
Decision Trees
Decision TreesDecision Trees
Decision Trees
 
Decision trees in Machine Learning
Decision trees in Machine Learning Decision trees in Machine Learning
Decision trees in Machine Learning
 
Types of clustering and different types of clustering algorithms
Types of clustering and different types of clustering algorithmsTypes of clustering and different types of clustering algorithms
Types of clustering and different types of clustering algorithms
 
My8clst
My8clstMy8clst
My8clst
 
K-Nearest Neighbor Classifier
K-Nearest Neighbor ClassifierK-Nearest Neighbor Classifier
K-Nearest Neighbor Classifier
 
Clustering
ClusteringClustering
Clustering
 
Introduction to Linear Discriminant Analysis
Introduction to Linear Discriminant AnalysisIntroduction to Linear Discriminant Analysis
Introduction to Linear Discriminant Analysis
 
08 clustering
08 clustering08 clustering
08 clustering
 
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
 
Random Forest and KNN is fun
Random Forest and KNN is funRandom Forest and KNN is fun
Random Forest and KNN is fun
 
2.1 Data Mining-classification Basic concepts
2.1 Data Mining-classification Basic concepts2.1 Data Mining-classification Basic concepts
2.1 Data Mining-classification Basic concepts
 
3.3 hierarchical methods
3.3 hierarchical methods3.3 hierarchical methods
3.3 hierarchical methods
 

Similaire à K nearest neighbor

Decision tree induction
Decision tree inductionDecision tree induction
Decision tree inductionthamizh arasi
 
Chap8 basic cluster_analysis
Chap8 basic cluster_analysisChap8 basic cluster_analysis
Chap8 basic cluster_analysisguru_prasadg
 
Chapter 10. Cluster Analysis Basic Concepts and Methods.ppt
Chapter 10. Cluster Analysis Basic Concepts and Methods.pptChapter 10. Cluster Analysis Basic Concepts and Methods.ppt
Chapter 10. Cluster Analysis Basic Concepts and Methods.pptSubrata Kumer Paul
 
CLUSTER ANALYSIS ALGORITHMS.pptx
CLUSTER ANALYSIS ALGORITHMS.pptxCLUSTER ANALYSIS ALGORITHMS.pptx
CLUSTER ANALYSIS ALGORITHMS.pptxShwetapadmaBabu1
 
Advanced data structures using c++ 3
Advanced data structures using c++ 3Advanced data structures using c++ 3
Advanced data structures using c++ 3Shaili Choudhary
 
Lecture 11
Lecture 11Lecture 11
Lecture 11Jeet Das
 
Statistical Clustering
Statistical ClusteringStatistical Clustering
Statistical Clusteringtim_hare
 
ML basic &amp; clustering
ML basic &amp; clusteringML basic &amp; clustering
ML basic &amp; clusteringmonalisa Das
 
Supervised and unsupervised learning
Supervised and unsupervised learningSupervised and unsupervised learning
Supervised and unsupervised learningAmAn Singh
 

Similaire à K nearest neighbor (20)

BAS 250 Lecture 5
BAS 250 Lecture 5BAS 250 Lecture 5
BAS 250 Lecture 5
 
Decision tree
Decision treeDecision tree
Decision tree
 
Decision tree
Decision treeDecision tree
Decision tree
 
Decision tree induction
Decision tree inductionDecision tree induction
Decision tree induction
 
Lect4
Lect4Lect4
Lect4
 
Decision trees
Decision treesDecision trees
Decision trees
 
Chap8 basic cluster_analysis
Chap8 basic cluster_analysisChap8 basic cluster_analysis
Chap8 basic cluster_analysis
 
Classification
ClassificationClassification
Classification
 
Classification
ClassificationClassification
Classification
 
Clustering
ClusteringClustering
Clustering
 
Chapter 10. Cluster Analysis Basic Concepts and Methods.ppt
Chapter 10. Cluster Analysis Basic Concepts and Methods.pptChapter 10. Cluster Analysis Basic Concepts and Methods.ppt
Chapter 10. Cluster Analysis Basic Concepts and Methods.ppt
 
CLUSTER ANALYSIS ALGORITHMS.pptx
CLUSTER ANALYSIS ALGORITHMS.pptxCLUSTER ANALYSIS ALGORITHMS.pptx
CLUSTER ANALYSIS ALGORITHMS.pptx
 
Advanced data structures using c++ 3
Advanced data structures using c++ 3Advanced data structures using c++ 3
Advanced data structures using c++ 3
 
Lecture 11
Lecture 11Lecture 11
Lecture 11
 
[PPT]
[PPT][PPT]
[PPT]
 
10 clusbasic
10 clusbasic10 clusbasic
10 clusbasic
 
Statistical Clustering
Statistical ClusteringStatistical Clustering
Statistical Clustering
 
ML basic &amp; clustering
ML basic &amp; clusteringML basic &amp; clustering
ML basic &amp; clustering
 
CLUSTERING
CLUSTERINGCLUSTERING
CLUSTERING
 
Supervised and unsupervised learning
Supervised and unsupervised learningSupervised and unsupervised learning
Supervised and unsupervised learning
 

Plus de Ujjawal

fMRI in machine learning
fMRI in machine learningfMRI in machine learning
fMRI in machine learningUjjawal
 
Random forest
Random forestRandom forest
Random forestUjjawal
 
Neural network for machine learning
Neural network for machine learningNeural network for machine learning
Neural network for machine learningUjjawal
 
Information retrieval
Information retrievalInformation retrieval
Information retrievalUjjawal
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithmUjjawal
 
Support vector machines
Support vector machinesSupport vector machines
Support vector machinesUjjawal
 
Vector space classification
Vector space classificationVector space classification
Vector space classificationUjjawal
 
Scoring, term weighting and the vector space
Scoring, term weighting and the vector spaceScoring, term weighting and the vector space
Scoring, term weighting and the vector spaceUjjawal
 
Bayes’ theorem and logistic regression
Bayes’ theorem and logistic regressionBayes’ theorem and logistic regression
Bayes’ theorem and logistic regressionUjjawal
 
Introduction to data mining
Introduction to data miningIntroduction to data mining
Introduction to data miningUjjawal
 

Plus de Ujjawal (10)

fMRI in machine learning
fMRI in machine learningfMRI in machine learning
fMRI in machine learning
 
Random forest
Random forestRandom forest
Random forest
 
Neural network for machine learning
Neural network for machine learningNeural network for machine learning
Neural network for machine learning
 
Information retrieval
Information retrievalInformation retrieval
Information retrieval
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
Support vector machines
Support vector machinesSupport vector machines
Support vector machines
 
Vector space classification
Vector space classificationVector space classification
Vector space classification
 
Scoring, term weighting and the vector space
Scoring, term weighting and the vector spaceScoring, term weighting and the vector space
Scoring, term weighting and the vector space
 
Bayes’ theorem and logistic regression
Bayes’ theorem and logistic regressionBayes’ theorem and logistic regression
Bayes’ theorem and logistic regression
 
Introduction to data mining
Introduction to data miningIntroduction to data mining
Introduction to data mining
 

Dernier

From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Cathrine Wilhelmsen
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
Multiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfMultiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfchwongval
 
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxNLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxBoston Institute of Analytics
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queensdataanalyticsqueen03
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...GQ Research
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectBoston Institute of Analytics
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryJeremy Anderson
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Seán Kennedy
 

Dernier (20)

From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
Multiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfMultiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdf
 
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxNLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queens
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis Project
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data Story
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...
 

K nearest neighbor

  • 1.
  • 2.  Classification is done by relating the unknown to the known according to some distance/similarity function  Stores all available cases and classifies new cases based on similarity measure  Different names  Memory-based reasoning  Example-based reasoning  Instance-based reasoning  Case-based reasoning  Lazy learning
  • 3.  kNN determines the decision boundary locally. Ex. for 1NN we assign each document to the class of its closest neighbor  For kNN we assign each document to the majority class of its closest neighbors where k is a parameter  The rationale of kNN classification is based on contiguity hypothesis, we expect the test document to have the same training label as the training documents located in the local region surrounding the document.  Veronoi tessellation of a set of objects decomposes space into Voronoi cells, where each object’s cell consist of all points that are closer to the object than to other objects.  It partitions the plane to complex polygons, each containing its corresponding document.
  • 4. Let k=3 P(circle class | star) = 1/3 P(X class | star) = 2/3 P(diamond class | star) = 0 3NN estimate is – P(circle class | star) = 1/3 1NN estimate is – P(circle class | star) = 1 3NN preferring X class and 1NN preferring circle class
  • 5.  Advantages  Non-parametric architecture  Simple  Powerful  Requires no training time  Disadvantages  Memory intensive  Classification/estimation is slow  The distance is calculated using Euclidean distance
  • 6. 2 21 2 21 )()( yyxxD 
  • 8. 2 21 2 21 )()( yyxxD 
  • 10.  If k=1, select the nearest neighbors  If k>1  For classification, select the most frequent neighbors  For regression, calculate the average of k neighbors
  • 11.
  • 12.  An inductive learning task – use particular facts to make more generalized conclusions  Predictive model based on branching series of Boolean test – these Boolean test are less complex than the one-stage classifier  Its learning from class labeled tuples  Can be used as visual aid to structure and solve sequential problems  Internal node (Non-leaf node) denotes a test on an attribute, each branch represents an outcome of the test and each leaf node holds a class label
  • 13. If we leave at 10 AM and there are no cars stalled on the road, what will our commute time be? Leave At Stall? Accident? 10 AM 9 AM 8 AM Long Long Short Medium Long No Yes No Yes
  • 14.  In this decision tree, we made a series of Boolean decision and followed a corresponding branch –  Did we leave at 10AM?  Did the car stall on road?  Is there an accident on the road?  By answering each of these questions as yes or no, we can come to a conclusion on how long our commute might take
  • 15.  We do not have to represent this tree graphically  We can represent this as a set of rules. However, it may be harder to read if hour == 8am commute time = long else if hour == 9am if accident == yes commute time = long else commute time = medium else if hour == 10am if stall == yes commute time = long else commute time = short
  • 16.  The algorithm is called with three parameters – data partition, attribute list, attribute subset selection.  It’s a set of tuples and there associated class label  Attribute list is a list of attributes describing the tuples  Attribute selection method specifies a heuristic procedure for selecting attribute that best discriminates the tuples  Tree starts at node N. if all the tuples in D are of the same class, then node N becomes a leaf and is labelled with that class  Else attribute selection method is used to determine the splitting criteria.  Node N is labelled with splitting criteria, which serves as a test at the node.
  • 17.
  • 18.
  • 19.  The previous experience decision table showed 4 attributes – hour, weather, accident and stall  But the decision tree showed three attributes – hour, attribute and stall  So which attribute is to be kept and which is to be removed?  Methods for selecting attribute shows that weather is not a discriminating attribute  Method – given a number of competing hypothesis, the simplest one is preferable  We will focus on ID3 algorithm
  • 20.  Basic idea  Choose the best attribute to split the remaining instances and make that attribute a decision node  Repeat this process for recursively for each child  Stop when  All attribute have same target attribute value  There are no more attributes  There are no more instances  ID3 splits attributes based on their entropy.  Entropy is a measure of disinformation
  • 21.  Entropy is minimized when all values of target attribute are the same  If we know that the commute time will be short, the entropy=0  Entropy is maximized when there is an equal chance of values for the target attribute (i.e. result is random)  If commute time = short in 3 instances, medium in 3 instances and long in 3 instances, entropy is maximized  Calculation of entropy  Entropy S = ∑(i=1 to l)-|Si|/|S| * log2(|Si|/|S|)  S = set of examples  Si = subset of S with value vi under the target attribute  L – size of range of target attribute
  • 22.
  • 23.  If we break down the leaving time to the minute, we might get something like this  Since the entropy is very less for each branch and we have n branches with n leaves. This would not be helpful for predictive modelling  We use a technique called as discretization. We choose cut point such as 9AM for splitting continuous attributes 8:02 AM 10:02 AM8:03 AM 9:09 AM9:05 AM 9:07 AM Long Medium Short Long Long Short
  • 24.  Consider the attribute commute time  When we split the attribute, we increase the entropy so we don’t have a decision tree with the same number of cut points as leaves 8:00 (L), 8:02 (L), 8:07 (M), 9:00 (S), 9:20 (S), 9:25 (S), 10:00 (S), 10:02 (M)
  • 25.  Binary decision trees  Classification of an input vector is done by traversing the tree beginning at the root node and ending at the leaf  Each node of the tree computes an inequality  Each leaf is assigned to a particular class  Input space is based on one input variable  Each node draws a boundary that can be geometrically interpreted as a hyperplane perpendicular to the axis
  • 26. B C Yes No Yes No NoYes BMI<24
  • 27.  They are similar to binary tree  Inequality computed at each node takes on a linear form that may depend on linear variable aX1+bX2 Yes No Yes No NoYes
  • 28.  Chi-squared automatic intersection detector(CHAID)  Non-binary decision tree  Decision made at each node is based on single variable, but can result in multiple branches  Continuous variables are grouped into a finite number of bins to create categories  Equal population bins is created for CHAID  Classification and Regression Trees (CART) are binary decision trees which split a single variable at each node  The CART algorithm goes through an exhaustive search of all variables and split values to find the optimal splitting rule for each node.
  • 29.  There is another technique for reducing the number of attributes used in tree – pruning  Two types of pruning  Pre-pruning (forward pruning)  Post-pruning (backward pruning)  Pre-pruning  We decide during the building process, when to stop adding attributes (possibly based on their information gain)  However, this may be problematic – why?  Sometimes, attribute individually do not compute much to a decision, but combined they may have significant impact.
  • 30.  Post-pruning waits until full decision tree has been built and then prunes the attributes.  Two techniques:  Subtree replacement  Subtree raising  Subtree replacement A B C 1 2 3 4 5
  • 31.  Node 6 replaced the subtree  May increase accuracy A B 6 4 5
  • 32.  Entire subtree is raised onto another node A B C 1 2 3 4 5 A C 1 2 3
  • 33.  While decision tree classifies quickly, the time taken for building the tree may be higher than any other type of classifier.  Decision tree suffer from problem of error propagation throughout the tree
  • 34.  Since decision trees work by a series of local decision, what happens if one of these decision is wrong?  Every decision from that point on may be wrong  We may return to the correct path of the tree