SlideShare a Scribd company logo
Buenos Aires, marzo de 2016
Eduardo Poggi
www.umiacs.umd.edu/~mrastega/
Instance Based Learning
 Distancias
 Introducción
 k-nearest neighbor
 Locally weighted regression
 Radial Basis Functions
 Case-Based Reasoning
 Reducción de instancias
Distancias
¿Y si es para algunos en lugar de para todos?¿Y si es para algunos en lugar de para todos?
Distancias
Distancias
Distancias
Distancias
Autos Motos Elect. Juguet. Golosinas Trigo Pollos
Autos 1 0.8 0.5 0.2 0.1 0 0
Motos 1 0.5 0.2 0.1 0 0
Elect. 1 0.2 0.1 0 0
Juguet. 1 0.1 0 0
Golosinas 1 0.5 0.5
Trigo 1 0.7
Pollos 1
Distancias
Distancia de Levenshtein, distancia de edición, o distancia entre palabras,
al número mínimo de operaciones requeridas para transformar una cadena de
caracteres en otra. Se entiende por operación: inserción, eliminación o la
sustitución de un carácter.
https://en.wikibooks.org/wiki/Algorithm_I
mplementation/Strings/Levenshtein_dista
nce#Python
Distancias
www.sc.ehu.es/ccwgrrom/transparencias/pdf-
vision-1-transparencias/capitulo-1.pdf
Distancias
http://www.nidokidos.org/thr
eads/29243-Animals-
humans-face-similarity-
funny-pics!!
Distancias
http://lear.inrialpes.fr/people/nowak/similarity/
Distancias
ProductoProducto
ComestiblesComestibles LimpiezaLimpieza IndumentariaIndumentaria
AnimalAnimal VegetalVegetal MineralMineral
LácteosLácteos CárnicosCárnicos
Leche liquidaLeche liquida Leche fermentadaLeche fermentada QuesosQuesos MantecaManteca
Yogurt enteroYogurt entero Yogurt descremadoYogurt descremado
Yogurt naturalYogurt natural Yogurt saborizadoYogurt saborizado
¿IBL?
 La idea es simple:
 La clase de una instancia debe ser similar a la clase asociada e ejemplos
parecidos.

Almacenar todo los ejemplos.

Cuando se recibe una instancia para clasificar se buscan los ejemplos “más
parecidos” y se analizan las clases asignadas.
 Pero:
 La clasificación puede ser costosa
 ¿Todos los atributos son igual de relevantes?
 ¿Cuántos son los ejemplos parecidos?
 ¿Si los ejemplos parecidos tienen clases disímiles?
 ¿Todos lso ejemplos parecidos “pesan” igual?
 ¿Qué tan parecidos deben ser los parecidos?
K-nearest neighbor
 To define how similar two examples are we need a metric.
 We assume all examples are points in an n-dimensional space Rn and use the
Euclidean distance:
 Let Xi and Xj be two examples. Their distance d(Xi,Xj) is defined as:
d(Xi, Xj) = ( Σk [xik – xjk]2 ) ** 1/2
Where xik is the value of attribute k on example Xi.
K-nearest neighbor for discrete classes
K = 4
New example
Nearest Neighbor
Four things make a memory based learner:
1. A distance metric
Euclidian
2. How many nearby neighbors to look at?
One
3. A weighting function (optional)
Unused
4. How to fit with the local points?
Just predict the same output as the nearest neighbor.
Voronoi Diagram
Decision surface induced by a 1-nearest neighbor. The decision
surface is a combination of convex polyhedra surrounding each
training example.
The Zen of Voronoi Diagrams
0 Nearest Neighbor
1 Nearest Neighbor
3 Nearest Neighbor
5 Nearest Neighbor
7 Nearest Neighbor
k-Nearest Neighbour Classification Method
 Key idea: keep all the training instances
 Given query example, take vote amongst its k neighbours
 Neighbours are determined by using a distance function
k-Nearest Neighbour Classification Method
(k=1)
(k=4)
Probability interpretation: estimate p(y|x) as
( ){ }, | , ( )
( | ) , ( ) is the neighborhood around
| ( ) |
i i i ix y y y x N x
p y x N x x
N x
= ∈
=
Sample adapted from Rong Jin’s slides
k-Nearest Neighbour Classification Method
 Advantages:
 Training is really fast
 Can learn complex target functions
 Disadvantages
 Slow at query time: Efficient data structures are needed to speed
up the query
How to choose k?
 Use validation with leave-one-out method
For k = 1, 2, …, K
Err(k) = 0;
1. Randomly select a training data point and
hide its class label
2. Using the remaining data and given k to
predict the class label for the left data point
3. Err(k) = Err(k) + 1 if the predicted label is
different from the true label
Repeat the procedure until all training examples
are tested
Choose the k whose Err(k) is minimal
How to choose k?
 Use validation with leave-one-out method
For k = 1, 2, …, K
Err(k) = 0;
1. Randomly select a training data point and
hide its class label
2. Using the remaining data and given k to
predict the class label for the left data point
3. Err(k) = Err(k) + 1 if the predicted label is
different from the true label
Repeat the procedure until all training examples
are tested
Choose the k whose Err(k) is minimal
How to choose k?
 Use validation with leave-one-out method
For k = 1, 2, …, K
Err(k) = 0;
1. Randomly select a training data point and
hide its class label
2. Using the remaining data and given k to
predict the class label for the left data point
3. Err(k) = Err(k) + 1 if the predicted label is
different from the true label
Repeat the procedure until all training examples
are tested
Choose the k whose Err(k) is minimal
(k=1)
How to choose k?
 Use validation with leave-one-out method
For k = 1, 2, …, K
Err(k) = 0;
1. Randomly select a training data point and
hide its class label
2. Using the remaining data and given k to
predict the class label for the left data point
3. Err(k) = Err(k) + 1 if the predicted label is
different from the true label
Repeat the procedure until all training examples
are tested
Choose the k whose Err(k) is minimal
Err(1) = 1
How to choose k?
 Use validation with leave-one-out method
For k = 1, 2, …, K
Err(k) = 0;
1. Randomly select a training data point and
hide its class label
2. Using the remaining data and given k to
predict the class label for the left data point
3. Err(k) = Err(k) + 1 if the predicted label is
different from the true label
Repeat the procedure until all training examples
are tested
Choose the k whose Err(k) is minimal
Err(1) = 1
How to choose k?
 Use validation with leave-one-out method
For k = 1, 2, …, K
Err(k) = 0;
1. Randomly select a training data point and
hide its class label
2. Using the remaining data and given k to
predict the class label for the left data point
3. Err(k) = Err(k) + 1 if the predicted label is
different from the true label
Repeat the procedure until all training examples
are tested
Choose the k whose Err(k) is minimal
Err(1) = 3
Err(2) = 2
Err(3) = 6
k = 2
K-nearest neighbor for discrete classes
 Algorithm (parameter k)
 For each training example (X,C(X)) add the example to our training
list.
 When a new example Xq arrives, assign class:

C(Xq) = majority voting on the k nearest neighbors of Xq

C(Xq) = argmax v Σi δ(v, C(Xi))
 where δ(a,b) = 1 if a = b and 0 otherwise
K-nearest neighbor for real-valued functions
 Algorithm (parameter k)
 For each training example (X,C(X))
 add the example to our training list.
 When a new example Xq arrives, assign class:
 C(Xq) = average value among k nearest neighbors of Xq
 C(Xq) = Σ C(Xi) / k
Distance Weighted Nearest Neighbor
 It makes sense to weight the contribution of each
example according to the distance to the new query
example.
 C(Xq) = argmax v Σi wi δ(v, C(Xi))
For example, wi = 1 / d(Xq,Xi)
Nearest Neighbor
Four things make a memory based learner:
1. A distance metric
Euclidian
2. How many nearby neighbors to look at?
k
3. A weighting function (optional)
1 / d(Xq,Xi)
4. How to fit with the local points?
Just predict the same output as the nearest neighbor.
Distance Weighted Nearest Neighbor for Real-Valued
Functions
 For real valued functions we average based on the weight
function and normalize using the sum of all weights.
 C(Xq) = Σi wi C(Xi) / Σ wi
Problems with k-nearest Neighbor
 The distance between examples is based on all attributes. What if some
attributes are irrelevant?
 Consider the curse of dimensionality.
 The larger the number of irrelevant attributes, the higher the effect on the
nearest-neighbor rule.
 One solution is to use weights on the attributes. This is like stretching or
contracting the dimensions on the input space.
 Ideally we would like to eliminate all irrelevant attributes.
Locally Weighted Regression
 Let’s remember some terminology:
 Regression: Is a problem similar to classification but the value to predict
is a real number.
 Residual: The difference between the true target value f and our
approximation f’: f(X) – f’(X)
 Kernel Function: The distance function that provides a weight to each
example. The kernel function K is a function of the distance between
examples: K = f(d(Xi,Xq))
Locally Weighted Regression
 The method is called locally weighted regression for the following
reasons:
 “Locally” because the predicted value for an example Xq is based only on
the vicinity or neighborhood around Xq.
 “Weighted” because the contribution of each neighbor of Xq will depend
on the distance between the neighbor example and Xq.
 “Regression” because the value to predict will be a real number.
Locally Weighted Regression
 Consider the problem of approximating a target function using a
linear combination of attribute values:
 f’(X) = w0 + w1x1 + w2x2 + … + wnxn
 where X = (x1, x2, …, xn)
 We want to find those coefficients that minimize the error: E = ½ Σk [f(X)
– f’(X)]2
Locally Weighted Regression
 If we do this in the vicinity of an example Xq and we wish to use a
kernel function, we get a form of locally weighted regression:
 E(Xq) = ½ Σk ( [f(X) – f’(X)]2 K(d(Xq,X) )
 where the sum now goes over the neighbors of Xq.
Locally Weighted Regression
 Using gradient descent search, the update rule is defined
as:

ΔΔ Wj = n Σk [f(X) – f’(X)] K(d(Xq,X) xj
 where n is the learning rate and xj is the jth attribute of example
X.
Locally Weighted Regression
Then here are some
commonly used
weighting functions…
(we use a Gaussian)
Nearest Neighbor
1. A distance metric
Scaled Euclidian
2. How many nearby neighbors to look at?
All of them
3. A weighting function (optional)
w_k = exp(-D(x_k , x_query )^2 / Kw^2 )
4. How to fit with the local points?
First form a local linear model. Find the β that
minimizes the locally weighted sum of squared residuals:
Locally Weighted Regression
 Remarks:
 The literature contains other functions that are non linear.
 There are many variations to locally weighted regression that use
different kernel functions.
 Normally a linear model is sufficiently good to approximate the local
neighborhood of an example.
Reducción de instancias
Reducción de instancias
Reducción de instancias
eduardopoggi@yahoo.com.ar
eduardo-poggi
http://ar.linkedin.com/in/eduardoapoggi
https://www.facebook.com/eduardo.poggi
@eduardoapoggi
Bibliografía

More Related Content

What's hot

MLHEP Lectures - day 2, basic track
MLHEP Lectures - day 2, basic trackMLHEP Lectures - day 2, basic track
MLHEP Lectures - day 2, basic track
arogozhnikov
 
K-means and GMM
K-means and GMMK-means and GMM
K-means and GMM
Sanghyuk Chun
 
Linear Discriminant Analysis and Its Generalization
Linear Discriminant Analysis and Its GeneralizationLinear Discriminant Analysis and Its Generalization
Linear Discriminant Analysis and Its Generalization
일상 온
 
Iwsm2014 an analogy-based approach to estimation of software development ef...
Iwsm2014   an analogy-based approach to estimation of software development ef...Iwsm2014   an analogy-based approach to estimation of software development ef...
Iwsm2014 an analogy-based approach to estimation of software development ef...
Nesma
 
Implicit schemes for wave models
Implicit schemes for wave modelsImplicit schemes for wave models
Implicit schemes for wave models
Mathieu Dutour Sikiric
 
MLHEP Lectures - day 1, basic track
MLHEP Lectures - day 1, basic trackMLHEP Lectures - day 1, basic track
MLHEP Lectures - day 1, basic track
arogozhnikov
 
Clustering:k-means, expect-maximization and gaussian mixture model
Clustering:k-means, expect-maximization and gaussian mixture modelClustering:k-means, expect-maximization and gaussian mixture model
Clustering:k-means, expect-maximization and gaussian mixture model
jins0618
 
Detailed Description on Cross Entropy Loss Function
Detailed Description on Cross Entropy Loss FunctionDetailed Description on Cross Entropy Loss Function
Detailed Description on Cross Entropy Loss Function
범준 김
 
20070823
2007082320070823
20070823neostar
 
Multiclass Logistic Regression: Derivation and Apache Spark Examples
Multiclass Logistic Regression: Derivation and Apache Spark ExamplesMulticlass Logistic Regression: Derivation and Apache Spark Examples
Multiclass Logistic Regression: Derivation and Apache Spark Examples
Marjan Sterjev
 
Support Vector Machines Simply
Support Vector Machines SimplySupport Vector Machines Simply
Support Vector Machines Simply
Emad Nabil
 
Reweighting and Boosting to uniforimty in HEP
Reweighting and Boosting to uniforimty in HEPReweighting and Boosting to uniforimty in HEP
Reweighting and Boosting to uniforimty in HEP
arogozhnikov
 
(DL hacks輪読) Variational Inference with Rényi Divergence
(DL hacks輪読) Variational Inference with Rényi Divergence(DL hacks輪読) Variational Inference with Rényi Divergence
(DL hacks輪読) Variational Inference with Rényi Divergence
Masahiro Suzuki
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical Methods
ESUG
 
Gaussian processing
Gaussian processingGaussian processing
Gaussian processing
홍배 김
 
Error Estimates for Multi-Penalty Regularization under General Source Condition
Error Estimates for Multi-Penalty Regularization under General Source ConditionError Estimates for Multi-Penalty Regularization under General Source Condition
Error Estimates for Multi-Penalty Regularization under General Source Condition
csandit
 
20 k-means, k-center, k-meoids and variations
20 k-means, k-center, k-meoids and variations20 k-means, k-center, k-meoids and variations
20 k-means, k-center, k-meoids and variations
Andres Mendez-Vazquez
 
K-Means Clustering Simply
K-Means Clustering SimplyK-Means Clustering Simply
K-Means Clustering Simply
Emad Nabil
 
机器学习Adaboost
机器学习Adaboost机器学习Adaboost
机器学习Adaboost
Shocky1
 

What's hot (20)

MLHEP Lectures - day 2, basic track
MLHEP Lectures - day 2, basic trackMLHEP Lectures - day 2, basic track
MLHEP Lectures - day 2, basic track
 
K-means and GMM
K-means and GMMK-means and GMM
K-means and GMM
 
Linear Discriminant Analysis and Its Generalization
Linear Discriminant Analysis and Its GeneralizationLinear Discriminant Analysis and Its Generalization
Linear Discriminant Analysis and Its Generalization
 
Iwsm2014 an analogy-based approach to estimation of software development ef...
Iwsm2014   an analogy-based approach to estimation of software development ef...Iwsm2014   an analogy-based approach to estimation of software development ef...
Iwsm2014 an analogy-based approach to estimation of software development ef...
 
Implicit schemes for wave models
Implicit schemes for wave modelsImplicit schemes for wave models
Implicit schemes for wave models
 
MLHEP Lectures - day 1, basic track
MLHEP Lectures - day 1, basic trackMLHEP Lectures - day 1, basic track
MLHEP Lectures - day 1, basic track
 
Clustering:k-means, expect-maximization and gaussian mixture model
Clustering:k-means, expect-maximization and gaussian mixture modelClustering:k-means, expect-maximization and gaussian mixture model
Clustering:k-means, expect-maximization and gaussian mixture model
 
Detailed Description on Cross Entropy Loss Function
Detailed Description on Cross Entropy Loss FunctionDetailed Description on Cross Entropy Loss Function
Detailed Description on Cross Entropy Loss Function
 
20070823
2007082320070823
20070823
 
Multiclass Logistic Regression: Derivation and Apache Spark Examples
Multiclass Logistic Regression: Derivation and Apache Spark ExamplesMulticlass Logistic Regression: Derivation and Apache Spark Examples
Multiclass Logistic Regression: Derivation and Apache Spark Examples
 
Support Vector Machines Simply
Support Vector Machines SimplySupport Vector Machines Simply
Support Vector Machines Simply
 
Reweighting and Boosting to uniforimty in HEP
Reweighting and Boosting to uniforimty in HEPReweighting and Boosting to uniforimty in HEP
Reweighting and Boosting to uniforimty in HEP
 
main
mainmain
main
 
(DL hacks輪読) Variational Inference with Rényi Divergence
(DL hacks輪読) Variational Inference with Rényi Divergence(DL hacks輪読) Variational Inference with Rényi Divergence
(DL hacks輪読) Variational Inference with Rényi Divergence
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical Methods
 
Gaussian processing
Gaussian processingGaussian processing
Gaussian processing
 
Error Estimates for Multi-Penalty Regularization under General Source Condition
Error Estimates for Multi-Penalty Regularization under General Source ConditionError Estimates for Multi-Penalty Regularization under General Source Condition
Error Estimates for Multi-Penalty Regularization under General Source Condition
 
20 k-means, k-center, k-meoids and variations
20 k-means, k-center, k-meoids and variations20 k-means, k-center, k-meoids and variations
20 k-means, k-center, k-meoids and variations
 
K-Means Clustering Simply
K-Means Clustering SimplyK-Means Clustering Simply
K-Means Clustering Simply
 
机器学习Adaboost
机器学习Adaboost机器学习Adaboost
机器学习Adaboost
 

Viewers also liked

Poggi analytics - tm - 1b
Poggi   analytics - tm - 1bPoggi   analytics - tm - 1b
Poggi analytics - tm - 1b
Gaston Liberman
 
M clase esp intelectual
M clase esp intelectualM clase esp intelectual
M clase esp intelectual
rocipe1977
 
DSMBiomedical_Robert Gibbons
DSMBiomedical_Robert GibbonsDSMBiomedical_Robert Gibbons
DSMBiomedical_Robert GibbonsRobert Gibbons
 
Data Steganography for Optical Color Image Cryptosystems
Data Steganography for Optical Color Image CryptosystemsData Steganography for Optical Color Image Cryptosystems
Data Steganography for Optical Color Image Cryptosystems
CSCJournals
 
Realism in Art and Architecture
Realism in Art and ArchitectureRealism in Art and Architecture
Realism in Art and Architecture
Andrea Fuentes
 
Did you Know -Fusion of FA & TA Analysis on GBIME
Did you Know -Fusion of FA  & TA Analysis on GBIMEDid you Know -Fusion of FA  & TA Analysis on GBIME
Did you Know -Fusion of FA & TA Analysis on GBIME
Sharechart Shrestha
 
Poggi analytics - trees - 1e
Poggi   analytics - trees - 1ePoggi   analytics - trees - 1e
Poggi analytics - trees - 1e
Gaston Liberman
 
Fiduciary Wellness 06/11/13 - 5 things you should be, and 5 things you should...
Fiduciary Wellness 06/11/13 - 5 things you should be, and 5 things you should...Fiduciary Wellness 06/11/13 - 5 things you should be, and 5 things you should...
Fiduciary Wellness 06/11/13 - 5 things you should be, and 5 things you should...
Michael Olah
 
B Ending Moments And Shearing Forces In Beams2
B Ending Moments And Shearing Forces In Beams2B Ending Moments And Shearing Forces In Beams2
B Ending Moments And Shearing Forces In Beams2Amr Hamed
 
Twitter for Critical Thinking
Twitter for Critical ThinkingTwitter for Critical Thinking
Twitter for Critical ThinkingDanielle Hinton
 
Presentation au
Presentation auPresentation au
Hybrid IBL in Organisational Studies
Hybrid IBL in Organisational StudiesHybrid IBL in Organisational Studies
Hybrid IBL in Organisational Studies
cilass.slideshare
 
Developing Partnerships for Educational Development from a CETL Perspective
Developing Partnerships for Educational Development from a CETL PerspectiveDeveloping Partnerships for Educational Development from a CETL Perspective
Developing Partnerships for Educational Development from a CETL Perspective
cilass.slideshare
 
Tailieu.vncty.com bao cao-chuyen_de_tot_nghiep_chu_5641
Tailieu.vncty.com   bao cao-chuyen_de_tot_nghiep_chu_5641Tailieu.vncty.com   bao cao-chuyen_de_tot_nghiep_chu_5641
Tailieu.vncty.com bao cao-chuyen_de_tot_nghiep_chu_5641
Trần Đức Anh
 
OK Bloggs, just watch the blackboard while I run through it: what has elearn...
OK Bloggs, just watch the blackboard while I run through it:  what has elearn...OK Bloggs, just watch the blackboard while I run through it:  what has elearn...
OK Bloggs, just watch the blackboard while I run through it: what has elearn...cilass.slideshare
 
Using Enquiry Based Learning to Create a Blended Academic Skills Development ...
Using Enquiry Based Learning to Create a Blended Academic Skills Development ...Using Enquiry Based Learning to Create a Blended Academic Skills Development ...
Using Enquiry Based Learning to Create a Blended Academic Skills Development ...
cilass.slideshare
 

Viewers also liked (18)

Poggi analytics - tm - 1b
Poggi   analytics - tm - 1bPoggi   analytics - tm - 1b
Poggi analytics - tm - 1b
 
M clase esp intelectual
M clase esp intelectualM clase esp intelectual
M clase esp intelectual
 
DSMBiomedical_Robert Gibbons
DSMBiomedical_Robert GibbonsDSMBiomedical_Robert Gibbons
DSMBiomedical_Robert Gibbons
 
SBT letter from JK
SBT letter from JKSBT letter from JK
SBT letter from JK
 
Data Steganography for Optical Color Image Cryptosystems
Data Steganography for Optical Color Image CryptosystemsData Steganography for Optical Color Image Cryptosystems
Data Steganography for Optical Color Image Cryptosystems
 
Realism in Art and Architecture
Realism in Art and ArchitectureRealism in Art and Architecture
Realism in Art and Architecture
 
Did you Know -Fusion of FA & TA Analysis on GBIME
Did you Know -Fusion of FA  & TA Analysis on GBIMEDid you Know -Fusion of FA  & TA Analysis on GBIME
Did you Know -Fusion of FA & TA Analysis on GBIME
 
Poggi analytics - trees - 1e
Poggi   analytics - trees - 1ePoggi   analytics - trees - 1e
Poggi analytics - trees - 1e
 
Fiduciary Wellness 06/11/13 - 5 things you should be, and 5 things you should...
Fiduciary Wellness 06/11/13 - 5 things you should be, and 5 things you should...Fiduciary Wellness 06/11/13 - 5 things you should be, and 5 things you should...
Fiduciary Wellness 06/11/13 - 5 things you should be, and 5 things you should...
 
Storyboard
StoryboardStoryboard
Storyboard
 
B Ending Moments And Shearing Forces In Beams2
B Ending Moments And Shearing Forces In Beams2B Ending Moments And Shearing Forces In Beams2
B Ending Moments And Shearing Forces In Beams2
 
Twitter for Critical Thinking
Twitter for Critical ThinkingTwitter for Critical Thinking
Twitter for Critical Thinking
 
Presentation au
Presentation auPresentation au
Presentation au
 
Hybrid IBL in Organisational Studies
Hybrid IBL in Organisational StudiesHybrid IBL in Organisational Studies
Hybrid IBL in Organisational Studies
 
Developing Partnerships for Educational Development from a CETL Perspective
Developing Partnerships for Educational Development from a CETL PerspectiveDeveloping Partnerships for Educational Development from a CETL Perspective
Developing Partnerships for Educational Development from a CETL Perspective
 
Tailieu.vncty.com bao cao-chuyen_de_tot_nghiep_chu_5641
Tailieu.vncty.com   bao cao-chuyen_de_tot_nghiep_chu_5641Tailieu.vncty.com   bao cao-chuyen_de_tot_nghiep_chu_5641
Tailieu.vncty.com bao cao-chuyen_de_tot_nghiep_chu_5641
 
OK Bloggs, just watch the blackboard while I run through it: what has elearn...
OK Bloggs, just watch the blackboard while I run through it:  what has elearn...OK Bloggs, just watch the blackboard while I run through it:  what has elearn...
OK Bloggs, just watch the blackboard while I run through it: what has elearn...
 
Using Enquiry Based Learning to Create a Blended Academic Skills Development ...
Using Enquiry Based Learning to Create a Blended Academic Skills Development ...Using Enquiry Based Learning to Create a Blended Academic Skills Development ...
Using Enquiry Based Learning to Create a Blended Academic Skills Development ...
 

Similar to Poggi analytics - distance - 1a

Instance Based Learning in Machine Learning
Instance Based Learning in Machine LearningInstance Based Learning in Machine Learning
Instance Based Learning in Machine Learning
Pavithra Thippanaik
 
instance bases k nearest neighbor algorithm.ppt
instance bases k nearest neighbor algorithm.pptinstance bases k nearest neighbor algorithm.ppt
instance bases k nearest neighbor algorithm.ppt
Johny139575
 
KNN.pptx
KNN.pptxKNN.pptx
KNN.pptx
dfgd7
 
Artificial Intelligence
Artificial Intelligence Artificial Intelligence
Artificial Intelligence butest
 
Knn 160904075605-converted
Knn 160904075605-convertedKnn 160904075605-converted
Knn 160904075605-converted
rameswara reddy venkat
 
ENBIS 2018 presentation on Deep k-Means
ENBIS 2018 presentation on Deep k-MeansENBIS 2018 presentation on Deep k-Means
ENBIS 2018 presentation on Deep k-Means
tthonet
 
Knn demonstration
Knn demonstrationKnn demonstration
Knn demonstration
Md. Abu Bakr Siddique
 
SkNoushadddoja_28100119039.pptx
SkNoushadddoja_28100119039.pptxSkNoushadddoja_28100119039.pptx
SkNoushadddoja_28100119039.pptx
PrakasBhowmik
 
Lecture 02: Machine Learning for Language Technology - Decision Trees and Nea...
Lecture 02: Machine Learning for Language Technology - Decision Trees and Nea...Lecture 02: Machine Learning for Language Technology - Decision Trees and Nea...
Lecture 02: Machine Learning for Language Technology - Decision Trees and Nea...
Marina Santini
 
Machine learning in science and industry — day 1
Machine learning in science and industry — day 1Machine learning in science and industry — day 1
Machine learning in science and industry — day 1
arogozhnikov
 
1519 differentiation-integration-02
1519 differentiation-integration-021519 differentiation-integration-02
1519 differentiation-integration-02
Dr Fereidoun Dejahang
 
MLHEP 2015: Introductory Lecture #1
MLHEP 2015: Introductory Lecture #1MLHEP 2015: Introductory Lecture #1
MLHEP 2015: Introductory Lecture #1
arogozhnikov
 
An_Accelerated_Nearest_Neighbor_Search_Method_for_the_K-Means_Clustering_Algo...
An_Accelerated_Nearest_Neighbor_Search_Method_for_the_K-Means_Clustering_Algo...An_Accelerated_Nearest_Neighbor_Search_Method_for_the_K-Means_Clustering_Algo...
An_Accelerated_Nearest_Neighbor_Search_Method_for_the_K-Means_Clustering_Algo...Adam Fausett
 
Information-theoretic clustering with applications
Information-theoretic clustering  with applicationsInformation-theoretic clustering  with applications
Information-theoretic clustering with applications
Frank Nielsen
 
Integral Calculus Anti Derivatives reviewer
Integral Calculus Anti Derivatives reviewerIntegral Calculus Anti Derivatives reviewer
Integral Calculus Anti Derivatives reviewer
JoshuaAgcopra
 
KNN presentation.pdf
KNN presentation.pdfKNN presentation.pdf
KNN presentation.pdf
AbhilashChauhan14
 

Similar to Poggi analytics - distance - 1a (20)

Cs345 cl
Cs345 clCs345 cl
Cs345 cl
 
Lect4
Lect4Lect4
Lect4
 
Instance Based Learning in Machine Learning
Instance Based Learning in Machine LearningInstance Based Learning in Machine Learning
Instance Based Learning in Machine Learning
 
instance bases k nearest neighbor algorithm.ppt
instance bases k nearest neighbor algorithm.pptinstance bases k nearest neighbor algorithm.ppt
instance bases k nearest neighbor algorithm.ppt
 
KNN.pptx
KNN.pptxKNN.pptx
KNN.pptx
 
KNN.pptx
KNN.pptxKNN.pptx
KNN.pptx
 
Artificial Intelligence
Artificial Intelligence Artificial Intelligence
Artificial Intelligence
 
Knn 160904075605-converted
Knn 160904075605-convertedKnn 160904075605-converted
Knn 160904075605-converted
 
ENBIS 2018 presentation on Deep k-Means
ENBIS 2018 presentation on Deep k-MeansENBIS 2018 presentation on Deep k-Means
ENBIS 2018 presentation on Deep k-Means
 
[PPT]
[PPT][PPT]
[PPT]
 
Knn demonstration
Knn demonstrationKnn demonstration
Knn demonstration
 
SkNoushadddoja_28100119039.pptx
SkNoushadddoja_28100119039.pptxSkNoushadddoja_28100119039.pptx
SkNoushadddoja_28100119039.pptx
 
Lecture 02: Machine Learning for Language Technology - Decision Trees and Nea...
Lecture 02: Machine Learning for Language Technology - Decision Trees and Nea...Lecture 02: Machine Learning for Language Technology - Decision Trees and Nea...
Lecture 02: Machine Learning for Language Technology - Decision Trees and Nea...
 
Machine learning in science and industry — day 1
Machine learning in science and industry — day 1Machine learning in science and industry — day 1
Machine learning in science and industry — day 1
 
1519 differentiation-integration-02
1519 differentiation-integration-021519 differentiation-integration-02
1519 differentiation-integration-02
 
MLHEP 2015: Introductory Lecture #1
MLHEP 2015: Introductory Lecture #1MLHEP 2015: Introductory Lecture #1
MLHEP 2015: Introductory Lecture #1
 
An_Accelerated_Nearest_Neighbor_Search_Method_for_the_K-Means_Clustering_Algo...
An_Accelerated_Nearest_Neighbor_Search_Method_for_the_K-Means_Clustering_Algo...An_Accelerated_Nearest_Neighbor_Search_Method_for_the_K-Means_Clustering_Algo...
An_Accelerated_Nearest_Neighbor_Search_Method_for_the_K-Means_Clustering_Algo...
 
Information-theoretic clustering with applications
Information-theoretic clustering  with applicationsInformation-theoretic clustering  with applications
Information-theoretic clustering with applications
 
Integral Calculus Anti Derivatives reviewer
Integral Calculus Anti Derivatives reviewerIntegral Calculus Anti Derivatives reviewer
Integral Calculus Anti Derivatives reviewer
 
KNN presentation.pdf
KNN presentation.pdfKNN presentation.pdf
KNN presentation.pdf
 

More from Gaston Liberman

Poggi analytics - sentiment - 1
Poggi   analytics - sentiment - 1Poggi   analytics - sentiment - 1
Poggi analytics - sentiment - 1
Gaston Liberman
 
Poggi analytics - geneticos - 1
Poggi   analytics - geneticos - 1Poggi   analytics - geneticos - 1
Poggi analytics - geneticos - 1
Gaston Liberman
 
Poggi analytics - ebl - 1
Poggi   analytics - ebl - 1Poggi   analytics - ebl - 1
Poggi analytics - ebl - 1
Gaston Liberman
 
Poggi analytics - star - 1a
Poggi   analytics - star - 1aPoggi   analytics - star - 1a
Poggi analytics - star - 1a
Gaston Liberman
 
Poggi analytics - inference - 1a
Poggi   analytics - inference - 1aPoggi   analytics - inference - 1a
Poggi analytics - inference - 1a
Gaston Liberman
 
Poggi analytics - ensamble - 1b
Poggi   analytics - ensamble - 1bPoggi   analytics - ensamble - 1b
Poggi analytics - ensamble - 1b
Gaston Liberman
 
Poggi analytics - concepts - 1a
Poggi   analytics - concepts - 1aPoggi   analytics - concepts - 1a
Poggi analytics - concepts - 1a
Gaston Liberman
 
Poggi analytics - ml - 1d
Poggi   analytics - ml - 1dPoggi   analytics - ml - 1d
Poggi analytics - ml - 1d
Gaston Liberman
 
Poggi analytics - intro - 1c
Poggi   analytics - intro - 1cPoggi   analytics - intro - 1c
Poggi analytics - intro - 1c
Gaston Liberman
 
Poggi analytics - bayes - 1a
Poggi   analytics - bayes - 1aPoggi   analytics - bayes - 1a
Poggi analytics - bayes - 1a
Gaston Liberman
 
Poggi analytics - clustering - 1
Poggi   analytics - clustering - 1Poggi   analytics - clustering - 1
Poggi analytics - clustering - 1
Gaston Liberman
 
Henrion poggi analytics - ann - 1
Henrion poggi   analytics - ann - 1Henrion poggi   analytics - ann - 1
Henrion poggi analytics - ann - 1
Gaston Liberman
 

More from Gaston Liberman (13)

Taller bd8
Taller bd8Taller bd8
Taller bd8
 
Poggi analytics - sentiment - 1
Poggi   analytics - sentiment - 1Poggi   analytics - sentiment - 1
Poggi analytics - sentiment - 1
 
Poggi analytics - geneticos - 1
Poggi   analytics - geneticos - 1Poggi   analytics - geneticos - 1
Poggi analytics - geneticos - 1
 
Poggi analytics - ebl - 1
Poggi   analytics - ebl - 1Poggi   analytics - ebl - 1
Poggi analytics - ebl - 1
 
Poggi analytics - star - 1a
Poggi   analytics - star - 1aPoggi   analytics - star - 1a
Poggi analytics - star - 1a
 
Poggi analytics - inference - 1a
Poggi   analytics - inference - 1aPoggi   analytics - inference - 1a
Poggi analytics - inference - 1a
 
Poggi analytics - ensamble - 1b
Poggi   analytics - ensamble - 1bPoggi   analytics - ensamble - 1b
Poggi analytics - ensamble - 1b
 
Poggi analytics - concepts - 1a
Poggi   analytics - concepts - 1aPoggi   analytics - concepts - 1a
Poggi analytics - concepts - 1a
 
Poggi analytics - ml - 1d
Poggi   analytics - ml - 1dPoggi   analytics - ml - 1d
Poggi analytics - ml - 1d
 
Poggi analytics - intro - 1c
Poggi   analytics - intro - 1cPoggi   analytics - intro - 1c
Poggi analytics - intro - 1c
 
Poggi analytics - bayes - 1a
Poggi   analytics - bayes - 1aPoggi   analytics - bayes - 1a
Poggi analytics - bayes - 1a
 
Poggi analytics - clustering - 1
Poggi   analytics - clustering - 1Poggi   analytics - clustering - 1
Poggi analytics - clustering - 1
 
Henrion poggi analytics - ann - 1
Henrion poggi   analytics - ann - 1Henrion poggi   analytics - ann - 1
Henrion poggi analytics - ann - 1
 

Recently uploaded

RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
BBPMedia1
 
5 Things You Need To Know Before Hiring a Videographer
5 Things You Need To Know Before Hiring a Videographer5 Things You Need To Know Before Hiring a Videographer
5 Things You Need To Know Before Hiring a Videographer
ofm712785
 
BeMetals Presentation_May_22_2024 .pdf
BeMetals Presentation_May_22_2024   .pdfBeMetals Presentation_May_22_2024   .pdf
BeMetals Presentation_May_22_2024 .pdf
DerekIwanaka1
 
Attending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learnersAttending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learners
Erika906060
 
Skye Residences | Extended Stay Residences Near Toronto Airport
Skye Residences | Extended Stay Residences Near Toronto AirportSkye Residences | Extended Stay Residences Near Toronto Airport
Skye Residences | Extended Stay Residences Near Toronto Airport
marketingjdass
 
20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf
tjcomstrang
 
Maksym Vyshnivetskyi: PMO Quality Management (UA)
Maksym Vyshnivetskyi: PMO Quality Management (UA)Maksym Vyshnivetskyi: PMO Quality Management (UA)
Maksym Vyshnivetskyi: PMO Quality Management (UA)
Lviv Startup Club
 
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-indiafalcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
Falcon Invoice Discounting
 
What is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdfWhat is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdf
seoforlegalpillers
 
Filing Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed GuideFiling Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed Guide
YourLegal Accounting
 
Sustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & EconomySustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & Economy
Operational Excellence Consulting
 
Introduction to Amazon company 111111111111
Introduction to Amazon company 111111111111Introduction to Amazon company 111111111111
Introduction to Amazon company 111111111111
zoyaansari11365
 
Premium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern BusinessesPremium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern Businesses
SynapseIndia
 
Cracking the Workplace Discipline Code Main.pptx
Cracking the Workplace Discipline Code Main.pptxCracking the Workplace Discipline Code Main.pptx
Cracking the Workplace Discipline Code Main.pptx
Workforce Group
 
3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx
tanyjahb
 
What are the main advantages of using HR recruiter services.pdf
What are the main advantages of using HR recruiter services.pdfWhat are the main advantages of using HR recruiter services.pdf
What are the main advantages of using HR recruiter services.pdf
HumanResourceDimensi1
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptx
Cynthia Clay
 
Enterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdfEnterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdf
KaiNexus
 
Memorandum Of Association Constitution of Company.ppt
Memorandum Of Association Constitution of Company.pptMemorandum Of Association Constitution of Company.ppt
Memorandum Of Association Constitution of Company.ppt
seri bangash
 
Accpac to QuickBooks Conversion Navigating the Transition with Online Account...
Accpac to QuickBooks Conversion Navigating the Transition with Online Account...Accpac to QuickBooks Conversion Navigating the Transition with Online Account...
Accpac to QuickBooks Conversion Navigating the Transition with Online Account...
PaulBryant58
 

Recently uploaded (20)

RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
 
5 Things You Need To Know Before Hiring a Videographer
5 Things You Need To Know Before Hiring a Videographer5 Things You Need To Know Before Hiring a Videographer
5 Things You Need To Know Before Hiring a Videographer
 
BeMetals Presentation_May_22_2024 .pdf
BeMetals Presentation_May_22_2024   .pdfBeMetals Presentation_May_22_2024   .pdf
BeMetals Presentation_May_22_2024 .pdf
 
Attending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learnersAttending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learners
 
Skye Residences | Extended Stay Residences Near Toronto Airport
Skye Residences | Extended Stay Residences Near Toronto AirportSkye Residences | Extended Stay Residences Near Toronto Airport
Skye Residences | Extended Stay Residences Near Toronto Airport
 
20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf
 
Maksym Vyshnivetskyi: PMO Quality Management (UA)
Maksym Vyshnivetskyi: PMO Quality Management (UA)Maksym Vyshnivetskyi: PMO Quality Management (UA)
Maksym Vyshnivetskyi: PMO Quality Management (UA)
 
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-indiafalcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
 
What is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdfWhat is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdf
 
Filing Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed GuideFiling Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed Guide
 
Sustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & EconomySustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & Economy
 
Introduction to Amazon company 111111111111
Introduction to Amazon company 111111111111Introduction to Amazon company 111111111111
Introduction to Amazon company 111111111111
 
Premium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern BusinessesPremium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern Businesses
 
Cracking the Workplace Discipline Code Main.pptx
Cracking the Workplace Discipline Code Main.pptxCracking the Workplace Discipline Code Main.pptx
Cracking the Workplace Discipline Code Main.pptx
 
3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx
 
What are the main advantages of using HR recruiter services.pdf
What are the main advantages of using HR recruiter services.pdfWhat are the main advantages of using HR recruiter services.pdf
What are the main advantages of using HR recruiter services.pdf
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptx
 
Enterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdfEnterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdf
 
Memorandum Of Association Constitution of Company.ppt
Memorandum Of Association Constitution of Company.pptMemorandum Of Association Constitution of Company.ppt
Memorandum Of Association Constitution of Company.ppt
 
Accpac to QuickBooks Conversion Navigating the Transition with Online Account...
Accpac to QuickBooks Conversion Navigating the Transition with Online Account...Accpac to QuickBooks Conversion Navigating the Transition with Online Account...
Accpac to QuickBooks Conversion Navigating the Transition with Online Account...
 

Poggi analytics - distance - 1a

  • 1. Buenos Aires, marzo de 2016 Eduardo Poggi www.umiacs.umd.edu/~mrastega/
  • 2. Instance Based Learning  Distancias  Introducción  k-nearest neighbor  Locally weighted regression  Radial Basis Functions  Case-Based Reasoning  Reducción de instancias
  • 3. Distancias ¿Y si es para algunos en lugar de para todos?¿Y si es para algunos en lugar de para todos?
  • 7. Distancias Autos Motos Elect. Juguet. Golosinas Trigo Pollos Autos 1 0.8 0.5 0.2 0.1 0 0 Motos 1 0.5 0.2 0.1 0 0 Elect. 1 0.2 0.1 0 0 Juguet. 1 0.1 0 0 Golosinas 1 0.5 0.5 Trigo 1 0.7 Pollos 1
  • 8. Distancias Distancia de Levenshtein, distancia de edición, o distancia entre palabras, al número mínimo de operaciones requeridas para transformar una cadena de caracteres en otra. Se entiende por operación: inserción, eliminación o la sustitución de un carácter. https://en.wikibooks.org/wiki/Algorithm_I mplementation/Strings/Levenshtein_dista nce#Python
  • 12. Distancias ProductoProducto ComestiblesComestibles LimpiezaLimpieza IndumentariaIndumentaria AnimalAnimal VegetalVegetal MineralMineral LácteosLácteos CárnicosCárnicos Leche liquidaLeche liquida Leche fermentadaLeche fermentada QuesosQuesos MantecaManteca Yogurt enteroYogurt entero Yogurt descremadoYogurt descremado Yogurt naturalYogurt natural Yogurt saborizadoYogurt saborizado
  • 13. ¿IBL?  La idea es simple:  La clase de una instancia debe ser similar a la clase asociada e ejemplos parecidos.  Almacenar todo los ejemplos.  Cuando se recibe una instancia para clasificar se buscan los ejemplos “más parecidos” y se analizan las clases asignadas.  Pero:  La clasificación puede ser costosa  ¿Todos los atributos son igual de relevantes?  ¿Cuántos son los ejemplos parecidos?  ¿Si los ejemplos parecidos tienen clases disímiles?  ¿Todos lso ejemplos parecidos “pesan” igual?  ¿Qué tan parecidos deben ser los parecidos?
  • 14. K-nearest neighbor  To define how similar two examples are we need a metric.  We assume all examples are points in an n-dimensional space Rn and use the Euclidean distance:  Let Xi and Xj be two examples. Their distance d(Xi,Xj) is defined as: d(Xi, Xj) = ( Σk [xik – xjk]2 ) ** 1/2 Where xik is the value of attribute k on example Xi.
  • 15. K-nearest neighbor for discrete classes K = 4 New example
  • 16. Nearest Neighbor Four things make a memory based learner: 1. A distance metric Euclidian 2. How many nearby neighbors to look at? One 3. A weighting function (optional) Unused 4. How to fit with the local points? Just predict the same output as the nearest neighbor.
  • 17. Voronoi Diagram Decision surface induced by a 1-nearest neighbor. The decision surface is a combination of convex polyhedra surrounding each training example.
  • 18. The Zen of Voronoi Diagrams
  • 24. k-Nearest Neighbour Classification Method  Key idea: keep all the training instances  Given query example, take vote amongst its k neighbours  Neighbours are determined by using a distance function
  • 25. k-Nearest Neighbour Classification Method (k=1) (k=4) Probability interpretation: estimate p(y|x) as ( ){ }, | , ( ) ( | ) , ( ) is the neighborhood around | ( ) | i i i ix y y y x N x p y x N x x N x = ∈ = Sample adapted from Rong Jin’s slides
  • 26. k-Nearest Neighbour Classification Method  Advantages:  Training is really fast  Can learn complex target functions  Disadvantages  Slow at query time: Efficient data structures are needed to speed up the query
  • 27. How to choose k?  Use validation with leave-one-out method For k = 1, 2, …, K Err(k) = 0; 1. Randomly select a training data point and hide its class label 2. Using the remaining data and given k to predict the class label for the left data point 3. Err(k) = Err(k) + 1 if the predicted label is different from the true label Repeat the procedure until all training examples are tested Choose the k whose Err(k) is minimal
  • 28. How to choose k?  Use validation with leave-one-out method For k = 1, 2, …, K Err(k) = 0; 1. Randomly select a training data point and hide its class label 2. Using the remaining data and given k to predict the class label for the left data point 3. Err(k) = Err(k) + 1 if the predicted label is different from the true label Repeat the procedure until all training examples are tested Choose the k whose Err(k) is minimal
  • 29. How to choose k?  Use validation with leave-one-out method For k = 1, 2, …, K Err(k) = 0; 1. Randomly select a training data point and hide its class label 2. Using the remaining data and given k to predict the class label for the left data point 3. Err(k) = Err(k) + 1 if the predicted label is different from the true label Repeat the procedure until all training examples are tested Choose the k whose Err(k) is minimal (k=1)
  • 30. How to choose k?  Use validation with leave-one-out method For k = 1, 2, …, K Err(k) = 0; 1. Randomly select a training data point and hide its class label 2. Using the remaining data and given k to predict the class label for the left data point 3. Err(k) = Err(k) + 1 if the predicted label is different from the true label Repeat the procedure until all training examples are tested Choose the k whose Err(k) is minimal Err(1) = 1
  • 31. How to choose k?  Use validation with leave-one-out method For k = 1, 2, …, K Err(k) = 0; 1. Randomly select a training data point and hide its class label 2. Using the remaining data and given k to predict the class label for the left data point 3. Err(k) = Err(k) + 1 if the predicted label is different from the true label Repeat the procedure until all training examples are tested Choose the k whose Err(k) is minimal Err(1) = 1
  • 32. How to choose k?  Use validation with leave-one-out method For k = 1, 2, …, K Err(k) = 0; 1. Randomly select a training data point and hide its class label 2. Using the remaining data and given k to predict the class label for the left data point 3. Err(k) = Err(k) + 1 if the predicted label is different from the true label Repeat the procedure until all training examples are tested Choose the k whose Err(k) is minimal Err(1) = 3 Err(2) = 2 Err(3) = 6 k = 2
  • 33. K-nearest neighbor for discrete classes  Algorithm (parameter k)  For each training example (X,C(X)) add the example to our training list.  When a new example Xq arrives, assign class:  C(Xq) = majority voting on the k nearest neighbors of Xq  C(Xq) = argmax v Σi δ(v, C(Xi))  where δ(a,b) = 1 if a = b and 0 otherwise
  • 34. K-nearest neighbor for real-valued functions  Algorithm (parameter k)  For each training example (X,C(X))  add the example to our training list.  When a new example Xq arrives, assign class:  C(Xq) = average value among k nearest neighbors of Xq  C(Xq) = Σ C(Xi) / k
  • 35. Distance Weighted Nearest Neighbor  It makes sense to weight the contribution of each example according to the distance to the new query example.  C(Xq) = argmax v Σi wi δ(v, C(Xi)) For example, wi = 1 / d(Xq,Xi)
  • 36. Nearest Neighbor Four things make a memory based learner: 1. A distance metric Euclidian 2. How many nearby neighbors to look at? k 3. A weighting function (optional) 1 / d(Xq,Xi) 4. How to fit with the local points? Just predict the same output as the nearest neighbor.
  • 37. Distance Weighted Nearest Neighbor for Real-Valued Functions  For real valued functions we average based on the weight function and normalize using the sum of all weights.  C(Xq) = Σi wi C(Xi) / Σ wi
  • 38. Problems with k-nearest Neighbor  The distance between examples is based on all attributes. What if some attributes are irrelevant?  Consider the curse of dimensionality.  The larger the number of irrelevant attributes, the higher the effect on the nearest-neighbor rule.  One solution is to use weights on the attributes. This is like stretching or contracting the dimensions on the input space.  Ideally we would like to eliminate all irrelevant attributes.
  • 39. Locally Weighted Regression  Let’s remember some terminology:  Regression: Is a problem similar to classification but the value to predict is a real number.  Residual: The difference between the true target value f and our approximation f’: f(X) – f’(X)  Kernel Function: The distance function that provides a weight to each example. The kernel function K is a function of the distance between examples: K = f(d(Xi,Xq))
  • 40. Locally Weighted Regression  The method is called locally weighted regression for the following reasons:  “Locally” because the predicted value for an example Xq is based only on the vicinity or neighborhood around Xq.  “Weighted” because the contribution of each neighbor of Xq will depend on the distance between the neighbor example and Xq.  “Regression” because the value to predict will be a real number.
  • 41. Locally Weighted Regression  Consider the problem of approximating a target function using a linear combination of attribute values:  f’(X) = w0 + w1x1 + w2x2 + … + wnxn  where X = (x1, x2, …, xn)  We want to find those coefficients that minimize the error: E = ½ Σk [f(X) – f’(X)]2
  • 42. Locally Weighted Regression  If we do this in the vicinity of an example Xq and we wish to use a kernel function, we get a form of locally weighted regression:  E(Xq) = ½ Σk ( [f(X) – f’(X)]2 K(d(Xq,X) )  where the sum now goes over the neighbors of Xq.
  • 43. Locally Weighted Regression  Using gradient descent search, the update rule is defined as:  ΔΔ Wj = n Σk [f(X) – f’(X)] K(d(Xq,X) xj  where n is the learning rate and xj is the jth attribute of example X.
  • 44. Locally Weighted Regression Then here are some commonly used weighting functions… (we use a Gaussian)
  • 45. Nearest Neighbor 1. A distance metric Scaled Euclidian 2. How many nearby neighbors to look at? All of them 3. A weighting function (optional) w_k = exp(-D(x_k , x_query )^2 / Kw^2 ) 4. How to fit with the local points? First form a local linear model. Find the β that minimizes the locally weighted sum of squared residuals:
  • 46. Locally Weighted Regression  Remarks:  The literature contains other functions that are non linear.  There are many variations to locally weighted regression that use different kernel functions.  Normally a linear model is sufficiently good to approximate the local neighborhood of an example.

Editor's Notes

  1. What is machine learning?
  2. What is machine learning?
  3. What is machine learning?
  4. What is machine learning?
  5. What is machine learning?
  6. What is machine learning?
  7. What is machine learning?
  8. What is machine learning?
  9. What is machine learning?
  10. What is machine learning?
  11. What is machine learning?
  12. What is machine learning?
  13. What is machine learning?
  14. What is machine learning?
  15. What is machine learning?
  16. What is machine learning?
  17. What is machine learning?
  18. What is machine learning?
  19. What is machine learning?
  20. What is machine learning?
  21. What is machine learning?
  22. What is machine learning?
  23. What is machine learning?
  24. What is machine learning?
  25. What is machine learning?
  26. What is machine learning?
  27. What is machine learning?
  28. What is machine learning?
  29. What is machine learning?
  30. What is machine learning?
  31. What is machine learning?
  32. What is machine learning?
  33. What is machine learning?
  34. What is machine learning?
  35. What is machine learning?
  36. What is machine learning?
  37. What is machine learning?
  38. What is machine learning?