Presentation is loading. Please wait.

Presentation is loading. Please wait.

Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Machine Learning – Lecture 2 Probability Density Estimation 21.04.2009 Bastian Leibe.

Similar presentations


Presentation on theme: "Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Machine Learning – Lecture 2 Probability Density Estimation 21.04.2009 Bastian Leibe."— Presentation transcript:

1 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Machine Learning – Lecture 2 Probability Density Estimation 21.04.2009 Bastian Leibe RWTH Aachen http://www.umic.rwth-aachen.de/multimedia leibe@umic.rwth-aachen.de TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA A AA A A A A A AAAAAA A AAAA A A A AA A Many slides adapted from B. Schiele

2 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Announcements Course webpage  http://www.umic.rwth-aachen.de/multimedia  Teaching  Machine Learning http://www.umic.rwth-aachen.de/multimedia  Slides will be made available on the webpage L2P electronic repository  Exercises and supplementary materials will be posted on the L2P Please subscribe to the lecture on the Campus system!  Important to get email announcements and L2P access! 2 B. Leibe

3 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Announcements Lecture slot on Wednesday 16:00-17:30h  Who has conflicts there?  Do we need an alternative slot? 3 B. Leibe

4 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Course Outline Fundamentals (2 weeks)  Bayes Decision Theory  Probability Density Estimation Discriminative Approaches (5 weeks)  Linear Discriminant Functions  Statistical Learning Theory & SVMs  Boosting, Decision Trees Generative Models (5 weeks)  Bayesian Networks  Markov Random Fields Regression Problems (2 weeks)  Gaussian Processes B. Leibe 4

5 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Recap: Bayes Decision Theory 5 B. Leibe Decision boundary Slide credit: Bernt Schiele Image source: C.M. Bishop, 2006

6 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Recap: Bayes Decision Theory Optimal decision rule  Decide for C 1 if  This is equivalent to  Which is again equivalent to (Likelihood-Ratio test) 6 B. Leibe Decision threshold  Slide credit: Bernt Schiele

7 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Recap: Bayes Decision Theory Decision regions: R 1, R 2, R 3, … 7 B. Leibe Slide credit: Bernt Schiele

8 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Recap: Classifying with Loss Functions In general, we can formalize this by introducing a loss matrix L kj Example: cancer diagnosis 8 B. Leibe Decision Truth

9 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Recap: Minimizing the Expected Loss Optimal solution is the one that minimizes the loss.  But: loss function depends on the true class, which is unknown. Solution: Minimize the expected loss This can be done by choosing the regions such that which is easy to do once we know the posterior class probabilities. 9 B. Leibe

10 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Recap: The Reject Option Classification errors arise from regions where the largest posterior probability is significantly less than 1.  These are the regions where we are relatively uncertain about class membership.  For some applications, it may be better to reject the automatic decision entirely in such a case and e.g. consult a human expert. 10 B. Leibe Image source: C.M. Bishop, 2006

11 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Topics of This Lecture Probability Density Estimation  General concepts  Gaussian distribution Parametric Methods  Maximum Likelihood approach  Bayesian vs. Frequentist views on probability  Bayesian Learning Non-Parametric Methods  Histograms  Kernel density estimation  K-Nearest Neighbors  k-NN for Classification  Bias-Variance tradeoff 11 B. Leibe

12 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Probability Density Estimation Up to now  Bayes optimal classification  Based on the probabilities How can we estimate (=learn) those probability densities?  Supervised training case: data and class labels are known.  Estimate the probability density for each class separately:  (For simplicity of notation, we will drop the class label in the following.) 12 B. Leibe Slide credit: Bernt Schiele

13 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Probability Density Estimation Data: x 1, x 2, x 3, x 4, … Estimate: p ( x ) Methods  Parametric representations  Non-parametric representations  Mixture models (next lecture) 13 B. Leibe Slide credit: Bernt Schiele

14 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 One-dimensional case  Mean ¹  Variance ¾ 2 Multi-dimensional case  Mean ¹  Covariance § The Gaussian (or Normal) Distribution 14 B. Leibe Image source: C.M. Bishop, 2006

15 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Gaussian Distribution – Properties Central Limit Theorem  “The distribution of the sum of N i.i.d. random variables becomes increasingly Gaussian as N grows.”  In practice, the convergence to a Gaussian can be very rapid.  This makes the Gaussian interesting for many applications. Example: N uniform [0,1] random variables. 15 B. Leibe Image source: C.M. Bishop, 2006

16 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Gaussian Distribution – Properties Quadratic Form  N depends on x through the exponent  Here, M is often called the Mahalanobis distance from ¹ to x. Shape of the Gaussian  § is a real, symmetric matrix.  We can therefore decompose it into its eigenvectors and thus obtain with.  Constant density on ellipsoids with main directions along the eigenvectors u i and scaling factors. 16 B. Leibe Image source: C.M. Bishop, 2006

17 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Gaussian Distribution – Properties Special cases  Full covariance matrix  General ellipsoid shape  Diagonal covariance matrix  Axis-aligned ellipsoid  Uniform variance  Hypersphere 17 B. Leibe Image source: C.M. Bishop, 2006

18 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Gaussian Distribution – Properties The marginals of a Gaussian are again Gaussians: 18 B. Leibe Image source: C.M. Bishop, 2006

19 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Topics of This Lecture Probability Density Estimation  General concepts  Gaussian distribution Parametric Methods  Maximum Likelihood approach  Bayesian vs. Frequentist views on probability  Bayesian Learning Non-Parametric Methods  Histograms  Kernel density estimation  K-Nearest Neighbors  k-NN for Classification  Bias-Variance tradeoff 19 B. Leibe

20 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Parametric Methods Given  Data  Parametric form of the distribution with parameters µ  E.g. for Gaussian distrib.: Learning  Estimation of the parameters µ Likelihood of µ  Probability that the data X have indeed been generated from a probability density with parameters µ 20 B. Leibe Slide adapted from Bernt Schiele

21 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Maximum Likelihood Approach Computation of the likelihood  Single data point:  Assumption: all data points are independent  Log-likelihood  Estimation of the parameters µ (Learning) –Maximize the likelihood –Minimize the negative log-likelihood 21 B. Leibe Slide credit: Bernt Schiele

22 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Maximum Likelihood Approach Likelihood: We want to obtain such that is maximized. 22 B. Leibe Slide credit: Bernt Schiele

23 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Maximum Likelihood Approach Minimizing the log-likelihood  How do we minimize a function?  Take the derivative and set it to zero. Log-likelihood for Normal distribution (1D case) 23 B. Leibe

24 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Maximum Likelihood Approach Minimizing the log-likelihood 24 B. Leibe

25 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Maximum Likelihood Approach We thus obtain In a similar fashion, we get is the Maximum Likelihood estimate for the parameters of a Gaussian distribution. This is a very important result. Unfortunately, it is wrong… 25 B. Leibe “sample mean” “sample variance”

26 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Maximum Likelihood Approach Or not wrong, but rather biased… Assume the samples x 1, x 2, …, x N come from a true Gaussian distribution with mean ¹ and variance ¾ 2  We can now compute the expectations of the ML estimates with respect to the data set values. It can be shown that  The ML estimate will underestimate the true variance. Corrected estimate: 26 B. Leibe

27 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Maximum Likelihood – Limitations Maximum Likelihood has several significant limitations  It systematically underestimates the variance of the distribution!  E.g. consider the case  Maximum-likelihood estimate:  We say ML overfits to the observed data.  We will still often use ML, but it is important to know about this effect. 27 B. Leibe Slide adapted from Bernt Schiele

28 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Deeper Reason Maximum Likelihood is a Frequentist concept  In the Frequentist view, probabilities are the frequencies of random, repeatable events.  These frequencies are fixed, but can be estimated more precisely when more data is available. This is in contrast to the Bayesian interpretation  In the Bayesian view, probabilities quantify the uncertainty about certain states or events.  This uncertainty can be revised in the light of new evidence. Bayesians and Frequentists do not like each other too well… 28 B. Leibe

29 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Bayesian vs. Frequentist View To see the difference…  Suppose we want to estimate the uncertainty whether the Arctic ice cap will have disappeared by the end of the century.  This question makes no sense in a Frequentist view, since the event cannot be repeated numerous times.  In the Bayesian view, we generally have a prior, e.g. from calculations how fast the polar ice is melting.  If we now get fresh evidence, e.g. from a new satellite, we may revise our opinion and update the uncertainty from the prior.  This generally allows to get better uncertainty estimates for many situations. Main Frequentist criticism  The prior has to come from somewhere and if it is wrong, the result will be worse. 29 B. Leibe

30 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Bayesian Approach to Parameter Learning Conceptual shift  Maximum Likelihood views the true parameter vector µ to be unknown, but fixed.  In Bayesian learning, we consider µ to be a random variable. This allows us to use knowledge about the parameters µ  i.e. to use a prior for µ  Training data then converts this prior distribution on µ into a posterior probability density.  The prior thus encodes knowledge we have about the type of distribution we expect to see for µ. 30 B. Leibe Slide adapted from Bernt Schiele

31 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Bayesian Learning Approach Bayesian view:  Consider the parameter vector µ as a random variable.  When estimating the parameters, what we compute is 31 B. Leibe This is entirely determined by the parameter µ (i.e. by the parametric form of the pdf). Slide adapted from Bernt Schiele Assumption: given µ, this doesn’t depend on X anymore

32 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Bayesian Learning Approach Inserting this above, we obtain 32 B. Leibe Slide credit: Bernt Schiele

33 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Bayesian Learning Approach Discussion  If we now plug in a (suitable) prior p ( µ ), we can estimate from the data set X. 33 B. Leibe Normalization: integrate over all possible values of µ Likelihood of the parametric form µ given the data set X. Prior for the parameters µ Estimate for x based on parametric form µ

34 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Bayesian Density Estimation Discussion  The probability makes the dependency of the estimate on the data explicit.  If is very small everywhere, but is large for one, then  The more uncertain we are about µ, the more we average over all parameter values. 34 B. Leibe Slide credit: Bernt Schiele

35 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Bayesian Density Estimation Problem  In the general case, the integration over µ is not possible (or only possible stochastically). Example where an analytical solution is possible  Normal distribution for the data, ¾ 2 assumed known and fixed.  Estimate the distribution of the mean:  Prior: We assume a Gaussian prior over ¹, 35 B. Leibe Slide credit: Bernt Schiele

36 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Bayesian Learning Approach Sample mean: Bayes estimate: Note: 36 B. Leibe Slide adapted from Bernt Schiele Image source: C.M. Bishop, 2006

37 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Summary: ML vs. Bayesian Learning Maximum Likelihood  Simple approach, often analytically possible.  Problem: estimation is biased, tends to overfit to the data.  Often needs some correction or regularization.  But: –Approximation gets accurate for. Bayesian Learning  General approach, avoids the estimation bias through a prior.  Problems: –Need to choose a suitable prior (not always obvious). –Integral over µ often not analytically feasible anymore.  But: –Efficient stochastic sampling techniques available (see Lecture 15). (In this lecture, we’ll use both concepts wherever appropriate) 37 B. Leibe

38 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Topics of This Lecture Probability Density Estimation  General concepts  Gaussian distribution Parametric Methods  Maximum Likelihood approach  Bayesian vs. Frequentist views on probability  Bayesian Learning Non-Parametric Methods  Histograms  Kernel density estimation  K-Nearest Neighbors  k-NN for Classification  Bias-Variance tradeoff 38 B. Leibe

39 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Non-Parametric Methods Non-parametric representations  Often the functional form of the distribution is unknown Estimate probability density from data  Histograms  Kernel density estimation (Parzen window / Gaussian kernels)  k-Nearest-Neighbor 39 B. Leibe Slide credit: Bernt Schiele

40 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Histograms Basic idea:  Partition the data space into distinct bins with widths ¢ i and count the number of observations, n i, in each bin.  Often, the same width is used for all bins, ¢ i = ¢.  This can be done, in principle, for any dimensionality D … 40 B. Leibe …but the required number of bins grows exponen- tially with D ! Image source: C.M. Bishop, 2006

41 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Histograms The bin width M acts as a smoothing factor. 41 B. Leibe not smooth enough about OK too smooth Image source: C.M. Bishop, 2006

42 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Summary: Histograms Properties  Very general. In the limit ( N !1 ), every probability density can be represented.  No need to store the data points once histogram is computed.  Rather brute-force Problems  High-dimensional feature spaces – D -dimensional space with M bins/dimension will require M D bins!  Requires an exponentially growing number of data points  “Curse of dimensionality”  Discontinuities at bin edges  Bin size? –too large: too much smoothing –too small: too much noise 42 B. Leibe Slide credit: Bernt Schiele

43 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Statistically Better-Founded Approach Data point x comes from pdf p ( x )  Probability that x falls into small region R If R is sufficiently small, p ( x ) is roughly constant  Let V be the volume of R If the number N of samples is sufficiently large, we can estimate P as 43 B. Leibe Slide credit: Bernt Schiele

44 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Statistically Better-Founded Approach Kernel methods  Example: Determine the number K of data points inside a fixed hypercube… 44 B. Leibe fixed V determine K fixed K determine V Kernel MethodsK-Nearest Neighbor Slide credit: Bernt Schiele

45 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Kernel Methods Parzen Window  Hypercube of dimension D with edge length h :  Probability density estimate: 45 B. Leibe “Kernel function” Slide credit: Bernt Schiele

46 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Kernel Methods: Parzen Window Interpretations 1.We place a kernel window k at location x and count how many data points fall inside it. 2.We place a kernel window k around each data point x n and sum up their influences at location x.  Direct visualization of the density. Still, we have artificial discontinuities at the cube boundaries…  We can obtain a smoother density model if we choose a smoother kernel function, e.g. a Gaussian 46 B. Leibe

47 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Kernel Methods: Gaussian Kernel Gaussian kernel  Kernel function  Probability density estimate 47 B. Leibe Slide credit: Bernt Schiele

48 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Gauss Kernel: Examples 48 B. Leibe not smooth enough about OK too smooth h acts as a smoother. Image source: C.M. Bishop, 2006

49 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Kernel Methods In general  Any kernel such that can be used. Then  And we get the probability density estimate 49 B. Leibe Slide adapted from Bernt Schiele

50 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Statistically Better-Founded Approach 50 B. Leibe fixed V determine K fixed K determine V Kernel MethodsK-Nearest Neighbor  Increase the volume V until the K next data points are found. Slide credit: Bernt Schiele

51 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 K-Nearest Neighbor Nearest-Neighbor density estimation  Fix K, estimate V from the data.  Consider a hypersphere centred on x and let it grow to a volume V ? that includes K of the given N data points.  Then Side note  Strictly speaking, the model produced by K-NN is not a true density model, because the integral over all space diverges.  E.g. consider K = 1 and a sample exactly on a data point x = x j. 51 B. Leibe

52 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 k-Nearest Neighbor: Examples 52 B. Leibe not smooth enough about OK too smooth K acts as a smoother. Image source: C.M. Bishop, 2006

53 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Summary: Kernel and k-NN Density Estimation Properties  Very general. In the limit ( N !1 ), every probability density can be represented.  No computation involved in the training phase  Simply storage of the training set Problems  Requires storing and computing with the entire dataset.  Computational cost linear in the number of data points.  This can be improved, at the expense of some computation during training, by constructing efficient tree-based search structures.  Kernel size / K in K-NN? –Too large: too much smoothing –Too small: too much noise 53 B. Leibe

54 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 K-Nearest Neighbor Classification Bayesian Classification Here we have 54 B. Leibe k-Nearest Neighbor classification Slide credit: Bernt Schiele

55 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 K-Nearest Neighbors for Classification 55 B. Leibe K = 1K = 3 Image source: C.M. Bishop, 2006

56 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 K-Nearest Neighbors for Classification Results on an example data set K acts as a smoothing parameter. Theoretical guarantee  For N !1, the error rate of the 1-NN classifier is never more than twice the optimal error (obtained from the true conditional class distributions). 56 B. Leibe Image source: C.M. Bishop, 2006

57 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Bias-Variance Tradeoff Probability density estimation  Histograms: bin size? – M too large: too smooth – M too small: not smooth enough  Kernel methods: kernel size? – h too large: too smooth – h too small: not smooth enough  K-Nearest Neighbor: K ? – K too large: too smooth – K too small: not smooth enough This is a general problem of many probability density estimation methods  Including parametric methods and mixture models 57 B. Leibe Too much bias Too much variance Slide credit: Bernt Schiele

58 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Discussion The methods discussed so far are all simple and easy to apply. They are used in many practical applications. However…  Histograms scale poorly with increasing dimensionality.  Only suitable for relatively low-dimensional data.  Both k-NN and kernel density estimation require the entire data set to be stored.  Too expensive if the data set is large.  Simple parametric models are very restricted in what forms of distributions they can represent.  Only suitable if the data has the same general form. We need density models that are efficient and flexible!  Next lecture… 58 B. Leibe

59 Perceptual and Sensory Augmented Computing Machine Learning Summer’09 References and Further Reading More information in Bishop’s book  Gaussian distribution and ML: Ch. 1.2.4 and 2.3.1-2.3.4.  Bayesian Learning: Ch. 1.2.3 and 2.3.6.  Nonparametric methods: Ch. 2.5. Additional information can be found in Duda & Hart  ML estimation:Ch. 3.2  Bayesian Learning:Ch. 3.3-3.5  Nonparametric methods:Ch. 4.1-4.5 B. Leibe 59 Christopher M. Bishop Pattern Recognition and Machine Learning Springer, 2006 R.O. Duda, P.E. Hart, D.G. Stork Pattern Classification 2 nd Ed., Wiley-Interscience, 2000


Download ppt "Perceptual and Sensory Augmented Computing Machine Learning Summer’09 Machine Learning – Lecture 2 Probability Density Estimation 21.04.2009 Bastian Leibe."

Similar presentations


Ads by Google