Professional Documents
Culture Documents
System LATEX 2
Vishwanathan]
A catalogue record for this book is available from the British Library
Library of Congress Cataloguing in Publication data available
ISBN 0 521 82583 0 hardback
Author: smola
Revision: 174
Timestamp: February 8, 2010
URL: svn://smola@repos.stat.purdue.edu/thebook/trunk/Book/thebook.tex
Contents
Preface
1
page 1
Introduction
1.1 A Taste of Machine Learning
1.1.1 Applications
1.1.2 Data
1.1.3 Problems
1.2 Probability Theory
1.2.1 Random Variables
1.2.2 Distributions
1.2.3 Mean and Variance
1.2.4 Marginalization, Independence, Conditioning, and
Bayes Rule
1.3 Basic Algorithms
1.3.1 Naive Bayes
1.3.2 Nearest Neighbor Estimators
1.3.3 A Simple Classifier
1.3.4 Perceptron
1.3.5 K-Means
3
3
3
7
9
12
12
13
15
16
20
22
25
27
29
32
Density Estimation
2.1 Limit Theorems
2.1.1 Fundamental Laws
2.1.2 The Characteristic Function
2.1.3 Tail Bounds
2.1.4 An Example
2.2 Parzen Windows
2.2.1 Discrete Density Estimation
2.2.2 Smoothing Kernel
2.2.3 Parameter Estimation
2.2.4 Silvermans Rule
2.2.5 Watson-Nadaraya Estimator
2.3 Exponential Families
2.3.1 Basics
37
37
38
42
45
48
51
51
52
54
57
59
60
60
v
vi
0 Contents
2.4
2.5
2.3.2 Examples
Estimation
2.4.1 Maximum Likelihood Estimation
2.4.2 Bias, Variance and Consistency
2.4.3 A Bayesian Approach
2.4.4 An Example
Sampling
2.5.1 Inverse Transformation
2.5.2 Rejection Sampler
62
64
66
68
71
75
77
78
82
89
90
90
92
93
96
98
100
102
103
106
108
108
108
111
113
113
119
120
122
123
123
124
124
Optimization
5.1 Preliminaries
5.1.1 Convex Sets
5.1.2 Convex Functions
5.1.3 Subgradients
5.1.4 Strongly Convex Functions
127
127
128
128
131
132
Contents
5.2
5.3
5.4
5.5
vii
Conditional Densities
6.1 Conditional Exponential Models
6.1.1 Basic Model
6.1.2 Joint Feature Map
6.1.3 Optimization
6.1.4 Gaussian Process Link
6.2 Binary Classification
6.2.1 Binomial Model
6.2.2 Optimization
6.3 Regression
6.3.1 Conditionally Normal Models
6.3.2 Posterior Distribution
6.3.3 Heteroscedastic Estimation
6.4 Multiclass Classification
6.4.1 Conditionally Multinomial Models
6.5 What is a CRF?
6.5.1 Linear Chain CRFs
6.5.2 Higher Order CRFs
6.5.3 Kernelized CRFs
6.6 Optimization Strategies
6.6.1 Getting Started
6.6.2 Optimization Algorithms
6.6.3 Handling Higher order CRFs
6.7 Hidden Markov Models
6.8 Further Reading
163
163
163
163
163
163
163
163
163
163
163
164
164
164
164
164
164
164
164
165
165
165
165
165
165
viii
0 Contents
6.8.1
Optimization
165
167
167
167
167
167
167
167
167
167
167
167
167
167
168
168
168
Linear Models
8.1 Support Vector Classification
8.1.1 A Regularized Risk Minimization Viewpoint
8.1.2 An Exponential Family Interpretation
8.1.3 Specialized Algorithms for Training SVMs
8.1.4 The trick
8.2 Support Vector Regression
8.2.1 Incorporating the Trick
8.2.2 Regularized Risk Minimization
8.3 Novelty Detection
8.3.1 Density Estimation via the Exponential Family
8.4 Ordinal Regression
8.4.1 Preferences
8.4.2 Dual Problem
8.4.3 Optimization
8.5 Margins and Probability
8.6 Large Margin Classifiers with Structure
8.6.1 Margin
8.6.2 Penalized Margin
8.6.3 Nonconvex Losses
8.7 Applications
8.7.1 Sequence Annotation
169
169
172
173
174
179
180
183
184
184
186
188
188
188
188
188
188
188
188
188
188
188
Contents
8.8
8.9
ix
8.7.2 Matching
8.7.3 Ranking
8.7.4 Shortest Path Planning
8.7.5 Image Annotation
8.7.6 Contingency Table Loss
Optimization
8.8.1 Column Generation
8.8.2 Bundle Methods
8.8.3 Overrelaxation in the Dual
CRFs vs Structured Large Margin Models
8.9.1 Loss Function
8.9.2 Dual Connections
8.9.3 Optimization
188
188
188
188
188
188
188
189
189
189
189
189
189
Model Selection
9.1 Basics
9.1.1 Estimators
9.1.2 Maximum Likelihood Revisited
9.1.3 Empirical Methods
9.2 Uniform Convergence Bounds
9.2.1 Vapnik Chervonenkis Dimension
9.2.2 Rademacher Averages
9.2.3 Compression Bounds
9.3 Bayesian Methods
9.3.1 Priors Revisited
9.3.2 PAC-Bayes Bounds
9.4 Asymptotic Analysis
9.4.1 Efficiency of an Estimator
9.4.2 Asymptotic Efficiency
191
191
191
191
191
191
191
191
191
191
191
191
191
191
192
10
193
193
193
193
193
193
193
193
193
193
193
0 Contents
10.4 Moments
10.4.1 Sufficient Statistics and the Marginal Polytope
10.5 Two Sample Test
10.5.1 Maximum Mean Discrepancy
10.5.2 Mean Map and Norm
10.5.3 Efficient Estimation
10.5.4 Covariate Shift Correction
10.6 Independence Measures
10.6.1 Test Statistic
10.6.2 Efficient Estimation
10.7 Applications
10.7.1 Independent Component Analysis
10.7.2 Feature Selection
10.7.3 Clustering
10.7.4 Maximum Variance Unfolding
10.8 Introduction
10.9 The Maximum Mean Discrepancy
10.9.1 Definition of the Maximum Mean Discrepancy
10.9.2 The MMD in Reproducing Kernel Hilbert Spaces
10.9.3 Witness Function of the MMD for RKHSs
10.9.4 The MMD in Other Function Classes
10.9.5 Examples of Non-RKHS Function Classes
10.10 Background Material
10.10.1Statistical Hypothesis Testing
10.10.2A Negative Result
10.10.3Previous Work
10.11 Tests Based on Uniform Convergence Bounds
10.11.1Bound on the Biased Statistic and Test
10.11.2Bound on the Unbiased Statistic and Test
10.12 Test Based on the Asymptotic Distribution of the Unbiased Statistic
10.13 A Linear Time Statistic and Test
10.14 Similarity Measures Related to MMD
10.14.1Link with L2 Distance between Parzen Window
Estimates
10.14.2Set Kernels and Kernels Between Probability
Measures
10.14.3Kernel Measures of Independence
10.14.4Kernel Statistics Using a Distribution over Witness
Functions
194
194
194
194
194
194
194
194
194
194
194
194
194
194
194
194
196
197
198
200
201
203
205
205
206
207
208
208
210
211
212
214
214
215
216
218
Contents
11
xi
10.14.5Outlier Detection
10.15 Experiments
10.15.1Toy Example: Two Gaussians
10.15.2Data Integration
10.15.3Computational Cost
10.15.4Attribute Matching
10.16 Conclusion
10.17 Large Deviation Bounds for Tests with Finite Sample
Guarantees
10.17.1Preliminary Definitions and Theorems
10.17.2Bound when p and q May Differ
10.17.3Bound when p = q and m = n
10.18 Proofs for Asymptotic Tests
10.18.1Convergence of the Empirical MMD under H0
10.18.2Moments of the Empirical MMD Under H0
219
219
220
221
223
224
228
Reinforcement Learning
239
230
230
230
232
233
234
236
Appendix 1
241
Appendix 2
Conjugate Distributions
242
Appendix 3
Bibliography
Loss Functions
244
261
Preface
0 Preface
Density
Estimation
Graphical
Models
Duality and
Estimation
Conditional
Densities
Linear Models
Kernels
Moment
Methods
Optimization
Conditional
Random Fields
Structured
Estimation
Reinforcement
Learning
Duality and
Estimation
Introduction
Introduction
Density
Estimation
Density
Estimation
Graphical
Models
Graphical
Models
Conditional
Densities
Kernels
Moment
Methods
Linear Models
Duality and
Estimation
Optimization
Conditional
Random Fields
Kernels
Structured
Estimation
Reinforcement
Learning
Conditional
Densities
Moment
Methods
Linear Models
Optimization
Conditional
Random Fields
Structured
Estimation
Reinforcement
Learning
1
Introduction
Over the past two decades Machine Learning has become one of the mainstays of information technology and with that, a rather central, albeit usually
hidden, part of our life. With the ever increasing amounts of data becoming
available there is good reason to believe that smart data analysis will become
even more pervasive as a necessary ingredient for technological progress.
The purpose of this chapter is to provide the reader with an overview over
the vast range of applications which have at their heart a machine learning
problem and to bring some degree of order to the zoo of problems. After
that, we will discuss some basic tools from statistics and probability theory,
since they form the language in which many machine learning problems must
be phrased to become amenable to solving. Finally, we will outline a set of
fairly basic yet effective algorithms to solve an important problem, namely
that of classification. More sophisticated tools, a discussion of more general
problems and a detailed analysis will follow in later parts of the book.
1.1.1 Applications
Most readers will be familiar with the concept of web page ranking. That
is, the process of submitting a query to a search engine, which then finds
webpages relevant to the query and which returns them in their order of
relevance. See e.g. Figure 1.1 for an example of the query results for machine learning. That is, the search engine returns a sorted list of webpages
given a query. To achieve this goal, a search engine needs to know which
3
1 Introduction
Web
Images
Maps
Web
News
Shopping
Gmail
more !
machine learning
Sign in
Search
Scholar
Advanced Search
Preferences
Sponsored Links
Machine Learning
Google Sydney needs machine
learning experts. Apply today!
www.google.com.au/jobs
Machine Learning is the study of computer algorithms that improve automatically through
experience. Applications range from datamining programs that ...
www.cs.cmu.edu/~tom/mlbook.html - 4k - Cached - Similar pages
machine learning
www.aaai.org/AITopics/html/machine.html - Similar pages
Machine Learning
A list of links to papers and other resources on machine learning.
www.machinelearning.net/ - 14k - Cached - Similar pages
pages are relevant and which pages match the query. Such knowledge can be
gained fromMachine
several
sources: the link structure of webpages, their content,
Learning Journal
the frequency with which users will follow the suggested links in a query, or
from examples
queries
CS 229:of
Machine
Learning in combination with manually ranked webpages.
Increasingly machine learning rather than guesswork and clever engineering
is used to automate the process of designing a good search engine [RPB06].
A rather related application is collaborative
filtering. Internet bookNext
stores such as Amazon, or video rental sites such as Netflix use this information extensively to entice users to purchase additional goods (or rent more
movies). The problem is quite similar to the one of web page ranking. As
before, we want to obtain a sorted list (in this case of articles). The key difference is that an explicit query is missing and instead we can only use past
purchase and viewing decisions of the user to predict future viewing and
purchase habits. The key side information here are the decisions made by
similar users, hence the collaborative nature of the process. See Figure 1.2
for an example. It is clearly desirable to have an automatic system to solve
this problem, thereby avoiding guesswork and time [BK07].
An equally ill-defined problem is that of automatic translation of documents. At one extreme, we could aim at fully understanding a text before
translating it using a curated set of rules crafted by a computational linguist
well versed in the two languages we would like to translate. This is a rather
arduous task, in particular given that text is not always grammatically correct, nor is the document understanding part itself a trivial one. Instead, we
could simply use examples of translated documents, such as the proceedings
of the Canadian parliament or other multilingual entities (United Nations,
European Union, Switzerland) to learn how to translate between the two
Amazon.com: Machine Learning: Tom M. Mitchell: Books.
www.amazon.com/Machine-Learning-Tom-M-Mitchell/dp/0070428077 - 210k Cached - Similar pages
Machine Learning publishes articles on the mechanisms through which intelligent systems
improve their performance over time. We invite authors to submit ...
pages.stern.nyu.edu/~fprovost/MLJ/ - 3k - Cached - Similar pages
STANFORD. CS229 Machine Learning Autumn 2007. Announcements. Final reports from
this year's class projects have been posted here. ...
cs229.stanford.edu/ - 10k - Cached - Similar pages
1 2 3 4 5 6 7 8 9 10
machine learning
Search
Search within results | Language Tools | Search Tips | Dissatisfied? Help us improve | Try Google Experimental
2008 Google - Google Home - Advertising Programs - Business Solutions - About Google
Today's Deals
Gift Cards
Books
Advanced Search
Books
Browse Subjects
Bestsellers
Libros En Espaol
Bargain Books
Textbooks
Join Amazon Prime and ship Two-Day for free and Overnight for $3.99. Already a member? Sign in.
Quantity:
by Thomas Mitchell (Author) "Ever since computers were invented, we have wondered whether
they might be made to learn..." (more)
or
Availability: Usually ships within 4 to 7 weeks. Ships from and sold by Amazon.com. Giftwrap available.
$153.44
$153.44
Better Together
Buy this book with Introduction to Machine Learning (Adaptive Computation and Machine Learning) by Ethem Alpaydin today!
Buy Together Today: $130.87
Artificial Intelligence: A
Modern Approach (2nd
Edition) (Prentice Hall
Series in Artificial
Intelligence) by Stuart
Russell
(76) $115.00
(50)
Editorial Reviews
Fig. 1.2. Books recommended by Amazon.com when viewing Tom Mitchells Machine Learning Book [Mit97]. It is desirable for the vendor to recommend relevant
books which a user might purchase.
Book Description
This exciting addition to the McGraw-Hill Series in Computer Science focuses on the concepts and techniques that contribute to the rapidly
changing field of machine learning--including probability and statistics, artificial intelligence, and neural networks--unifying them all in a logical
and coherent manner. Machine Learning serves as a useful reference tool for software developers and researchers, as well as an outstanding text
for college students. --This text refers to the Hardcover edition.
Book Info
Presents the key algorithms and theory that form the core of machine learning. Discusses such theoretical issues as How does learning
performance vary with the number of training examples presented? and Which learning algorithms are most appropriate for various types of
learning tasks? DLC: Computer algorithms. --This text refers to the Hardcover edition.
Product Details
Paperback: 352 pages
Publisher: McGraw-Hill Education (ISE Editions); 1st edition (October 1, 1997)
Language: English
ISBN-10: 0071154671
ISBN-13: 978-0071154673
Product Dimensions: 9 x 5.9 x 1.1 inches
Shipping Weight: 1.2 pounds (View shipping rates and policies)
Fig. 1.3. 11 Pictures of the same person taken from the Yale face recognition
database. The challenge is to recognize that we are dealing with the same person in all 11 cases.
Average Customer Review:
(What's this?)
#11 in Books > Computers & Internet > Computer Science > Artificial Intelligence > Machine Learning
Would you like to update product info or give feedback on images? (We'll ask you to sign in so we can get back to you)
(learn more)
Browse and search another edition of this book.
First Sentence:
Ever since computers were invented, we have wondered whether they might be made to learn. Read the first page
Browse Sample Pages:
Front Cover | Copyright | Table of Contents | Excerpt | Index | Back Cover | Surprise Me!
Search Inside This Book:
(What's this?)
(What's this?)
computer science
(6)
artificial intelligence
(2)
(1)
pattern recognition
(1)
1 Introduction
Fig. 1.4. Named entity tagging of a news article (using LingPipe). The relevant
locations, organizations and persons are tagged for further information extraction.
are clearly terms from agriculture, it is equally clear that in the context of
contemporary politics they refer to members of the Republican Party.
Other applications which take advantage of learning are speech recognition (annotate an audio sequence with text, such as the system shipping
with Microsoft Vista), the recognition of handwriting (annotate a sequence
of strokes with text, a feature common to many PDAs), trackpads of computers (e.g. Synaptics, a major manufacturer of such pads derives its name
from the synapses of a neural network), the detection of failure in jet engines, avatar behavior in computer games (e.g. Black and White), direct
marketing (companies use past purchase behavior to guesstimate whether
you might be willing to purchase even more) and floor cleaning robots (such
as iRobots Roomba). The overarching theme of learning problems is that
there exists a nontrivial dependence between some observations, which we
will commonly refer to as x and a desired response, which we refer to as y,
for which a simple set of deterministic rules is not known. By using learning
we can infer such a dependency between x and y in a systematic fashion.
We conclude this section by discussing the problem of classification,
since it will serve as a prototypical problem for a significant part of this
book. It occurs frequently in practice: for instance, when performing spam
filtering, we are interested in a yes/no answer as to whether an e-mail contains relevant information or not. Note that this issue is quite user dependent: for a frequent traveller e-mails from an airline informing him about
recent discounts might prove valuable information, whereas for many other
recipients this might prove more of an nuisance (e.g. when the e-mail relates
to products available only overseas). Moreover, the nature of annoying emails might change over time, e.g. through the availability of new products
(Viagra, Cialis, Levitra, . . . ), different opportunities for fraud (the Nigerian
419 scam which took a new twist after the Iraq war), or different data types
(e.g. spam which consists mainly of images). To combat these problems we
Fig. 1.5. Binary classification; separate stars from diamonds. In this example we
are able to do so by drawing a straight line which separates both sets. We will see
later that this is an important example of what is called a linear classifier.
want to build a system which is able to learn how to classify new e-mails.
A seemingly unrelated problem, that of cancer diagnosis shares a common
structure: given histological data (e.g. from a microarray analysis of a patients tissue) infer whether a patient is healthy or not. Again, we are asked
to generate a yes/no answer given a set of observations. See Figure 1.5 for
an example.
1.1.2 Data
It is useful to characterize learning problems according to the type of data
they use. This is a great help when encountering new challenges, since quite
often problems on similar data types can be solved with very similar techniques. For instance natural language processing and bioinformatics use very
similar tools for strings of natural language text and for DNA sequences.
Vectors constitute the most basic entity we might encounter in our work.
For instance, a life insurance company might be interesting in obtaining the
vector of variables (blood pressure, heart rate, height, weight, cholesterol
level, smoker, gender) to infer the life expectancy of a potential customer.
A farmer might be interested in determining the ripeness of fruit based on
(size, weight, spectral data). An engineer might want to find dependencies
in (voltage, current) pairs. Likewise one might want to represent documents
by a vector of counts which describe the occurrence of words. The latter is
commonly referred to as bag of words features.
One of the challenges in dealing with vectors is that the scales and units
of different coordinates may vary widely. For instance, we could measure the
height in kilograms, pounds, grams, tons, stones, all of which would amount
to multiplicative changes. Likewise, when representing temperatures, we
have a full class of affine transformations, depending on whether we represent them in terms of Celsius, Kelvin or Farenheit. One way of dealing
1 Introduction
1.1.3 Problems
The range of learning problems is clearly large, as we saw when discussing
applications. That said, researchers have identified an ever growing number
of templates which can be used to address a large set of situations. It is those
templates which make deployment of machine learning in practice easy and
our discussion will largely focus on a choice set of such problems. We now
give a by no means complete list of templates.
Binary Classification is probably the most frequently studied problem
in machine learning and it has led to a large number of important algorithmic
and theoretic developments over the past century. In its simplest form it
reduces to the question: given a pattern x drawn from a domain X, estimate
which value an associated binary random variable y {1} will assume.
For instance, given pictures of apples and oranges, we might want to state
whether the object in question is an apple or an orange. Equally well, we
might want to predict whether a home owner might default on his loan,
given income data, his credit history, or whether a given e-mail is spam or
ham. The ability to solve this basic problem already allows us to address a
large variety of practical settings.
There are many variants exist with regard to the protocol in which we are
required to make our estimation:
10
1 Introduction
Fig. 1.6. Left: binary classification. Right: 3-class classification. Note that in the
latter case we have much more degree for ambiguity. For instance, being able to
distinguish stars from diamonds may not suffice to identify either of them correctly,
since we also need to distinguish both of them from triangles.
11
error we make. For instance, in the problem of assessing the risk of cancer, it
makes a significant difference whether we mis-classify an early stage of cancer as healthy (in which case the patient is likely to die) or as an advanced
stage of cancer (in which case the patient is likely to be inconvenienced from
overly aggressive treatment).
Structured Estimation goes beyond simple multiclass estimation by
assuming that the labels y have some additional structure which can be used
in the estimation process. For instance, y might be a path in an ontology,
when attempting to classify webpages, y might be a permutation, when
attempting to match objects, to perform collaborative filtering, or to rank
documents in a retrieval setting. Equally well, y might be an annotation of
a text, when performing named entity recognition. Each of those problems
has its own properties in terms of the set of y which we might consider
admissible, or how to search this space. We will discuss a number of those
problems in Chapter ??.
Regression is another prototypical application. Here the goal is to estimate a real-valued variable y R given a pattern x (see e.g. Figure 1.7). For
instance, we might want to estimate the value of a stock the next day, the
yield of a semiconductor fab given the current process, the iron content of
ore given mass spectroscopy measurements, or the heart rate of an athlete,
given accelerometer data. One of the key issues in which regression problems
differ from each other is the choice of a loss. For instance, when estimating
stock values our loss for a put option will be decidedly one-sided. On the
other hand, a hobby athlete might only care that our estimate of the heart
rate matches the actual on average.
Novelty Detection is a rather ill-defined problem. It describes the issue
of determining unusual observations given a set of past measurements.
Clearly, the choice of what is to be considered unusual is very subjective.
A commonly accepted notion is that unusual events occur rarely. Hence a
possible goal is to design a system which assigns to each observation a rating
12
1 Introduction
Fig. 1.8. Left: typical digits contained in the database of the US Postal Service.
Right: unusual digits found by a novelty detection algorithm [SPST+ 01] (for a
description of the algorithm see Section 8.3). The score below the digits indicates
the degree of novelty. The numbers on the lower right indicate the class associated
with the digit.
as to how novel it is. Readers familiar with density estimation might contend
that the latter would be a reasonable solution. However, we neither need a
score which sums up to 1 on the entire domain, nor do we care particularly
much about novelty scores for typical observations. We will later see how this
somewhat easier goal can be achieved directly. Figure 1.8 has an example of
novelty detection when applied to an optical character recognition database.
13
height
(x)
weight
Fig. 1.9. The random variable maps from the set of outcomes of an experiment
(denoted here by X) to real numbers. As an illustration here X consists of the
patients a physician might encounter, and they are mapped via to their weight
and height.
1.2.2 Distributions
Perhaps the most important way to characterize a random variable is to
associate probabilities with the values it can take. If the random variable is
discrete, i.e., it takes on a finite number of values, then this assignment of
probabilities is called a probability mass function or PMF for short. A PMF
must be, by definition, non-negative and must sum to one. For instance,
if the coin is fair, i.e., heads and tails are equally likely, then the random
variable X described above takes on values of +1 and 1 with probability
0.5. This can be written as
P r(X = +1) = 0.5 and P r(X = 1) = 0.5.
(1.1)
When there is no danger of confusion we will use the slightly informal notation p(x) := P r(X = x).
In case of a continuous random variable the assignment of probabilities
results in a probability density function or PDF for short. With some abuse
of terminology, but keeping in line with convention, we will often use density
or distribution instead of probability density function. As in the case of the
PMF, a PDF must also be non-negative and integrate to one. Figure 1.10
shows two distributions: the uniform distribution
p(x) =
1
ba
if x [a, b]
otherwise,
(1.2)
14
1 Introduction
0.5
0.5
0.4
0.4
0.3
0.3
0.2
0.2
0.1
0.1
0.0
0.0
-4
-2
-4
-2
Fig. 1.10. Two common densities. Left: uniform distribution over the interval
[1, 1]. Right: Normal distribution with zero mean and unit variance.
1
2 2
exp
(x )2
2 2
(1.3)
Closely associated with a PDF is the indefinite integral over p. It is commonly referred to as the cumulative distribution function (CDF).
Definition 1.1 (Cumulative Distribution Function) For a real valued
random variable X with PDF p the associated Cumulative Distribution Function F is given by
x
F (x ) := Pr X x
dp(x).
(1.4)
Pr(a X b) =
(1.5)
The values of x for which F (x ) assumes a specific value, such as 0.1 or 0.5
have a special name. They are called the quantiles of the distribution p.
Definition 1.2 (Quantiles) Let q (0, 1). Then the value of x for which
Pr(X < x ) q and Pr(X > x ) 1 q is the q-quantile of the distribution
p. Moreover, the value x associated with q = 0.5 is called the median.
15
p(x)
Fig. 1.11. Quantiles of a distribution correspond to the area under the integral of
the density p(x) for which the integral takes on a pre-specified value. Illustrated
are the 0.1, 0.5 and 0.9 quantiles respectively.
xdp(x)
(1.6)
f (x)dp(x).
(1.7)
Whenever X is a discrete random variable the integral in (1.6) can be replaced by a summation:
E[X] =
xp(x).
(1.8)
For instance, in the case of a dice we have equal probabilities of 1/6 for all
6 possible outcomes. It is easy to see that this translates into a mean of
(1 + 2 + 3 + 4 + 5 + 6)/6 = 3.5.
The mean of a random variable is useful in assessing expected losses and
benefits. For instance, as a stock broker we might be interested in the expected value of our investment in a years time. In addition to that, however,
we also might want to investigate the risk of our investment. That is, how
likely it is that the value of the investment might deviate from its expectation since this might be more relevant for our decisions. This means that we
16
1 Introduction
need a variable to quantify the risk inherent in a random variable. One such
measure is the variance of a random variable.
Definition 1.4 (Variance) We define the variance of a random variable
X as
Var[X] := E (X E[X])2 .
(1.9)
(1.10)
The variance measures by how much on average f (X) deviates from its expected value. As we shall see in Section 2.1, an upper bound on the variance
can be used to give guarantees on the probability that f (X) will be within
of its expected value. This is one of the reasons why the variance is often
associated with the risk of a random variable. Note that often one discusses
properties of a random variable in terms of its standard deviation, which is
defined as the square root of the variance.
dp(x, y).
(1.11)
p(x, y).
(1.12)
We say that X and Y are independent, i.e., the values that X takes does
not depend on the values that Y takes whenever
p(x, y) = p(x)p(y).
(1.13)
Independence is useful when it comes to dealing with large numbers of random variables whose behavior we want to estimate jointly. For instance,
whenever we perform repeated measurements of a quantity, such as when
17
2.0
2.0
1.5
1.5
1.0
1.0
0.5
0.5
0.0
0.0
-0.5
-0.5
0.0
0.5
1.0
1.5
2.0
-0.5
-0.5
0.0
0.5
1.0
1.5
2.0
Fig. 1.12. Left: a sample from two dependent random variables. Knowing about
first coordinate allows us to improve our guess about the second coordinate. Right:
a sample drawn from two independent random variables, obtained by randomly
permuting the dependent sample.
measuring the voltage of a device, we will typically assume that the individual measurements are drawn from the same distribution and that they are
independent of each other. That is, having measured the voltage a number
of times will not affect the value of the next measurement. We will call such
random variables to be independently and identically distributed, or in short,
iid random variables. See Figure 1.12 for an example of a pair of random
variables drawn from dependent and independent distributions respectively.
Conversely, dependence can be vital in classification and regression problems. For instance, the traffic lights at an intersection are dependent of each
other. This allows a driver to perform the inference that when the lights are
green in his direction there will be no traffic crossing his path, i.e. the other
lights will indeed be red. Likewise, whenever we are given a picture x of a
digit, we hope that there will be dependence between x and its label y.
Especially in the case of dependent random variables, we are interested
in conditional probabilities, i.e., probability that X takes on a particular
value given the value of Y . Clearly P r(X = rain|Y = cloudy) is higher than
P r(X = rain|Y = sunny). In other words, knowledge about the value of Y
significantly influences the distribution of X. This is captured via conditional
probabilities:
p(x|y) :=
p(x, y)
.
p(y)
(1.14)
18
1 Introduction
p(x|y)p(y)
.
p(x)
(1.15)
This follows from the fact that p(x, y) = p(x|y)p(y) = p(y|x)p(x). The key
consequence of (1.15) is that we may reverse the conditioning between a
pair of random variables.
1.2.4.1 An Example
We illustrate our reasoning by means of a simple example inference using
an AIDS test. Assume that a patient would like to have such a test carried
out on him. The physician recommends a test which is guaranteed to detect
HIV-positive whenever a patient is infected. On the other hand, for healthy
patients it has a 1% error rate. That is, with probability 0.01 it diagnoses
a patient as HIV-positive even when he is, in fact, HIV-negative. Moreover,
assume that 0.15% of the population is infected.
Now assume that the patient has the test carried out and the test returns HIV-negative. In this case, logic implies that he is healthy, since the
test has 100% detection rate. In the converse case things are not quite as
straightforward. Denote by X and T the random variables associated with
the health status of the patient and the outcome of the test respectively. We
are interested in p(X = HIV+|T = HIV+). By Bayes rule we may write
p(X = HIV+|T = HIV+) =
While we know all terms in the numerator, p(T = HIV+) itself is unknown.
That said, it can be computed via
p(T = HIV+) =
p(T = HIV+, x)
x{HIV+,HIV-}
p(T = HIV+|x)p(x)
x{HIV+,HIV-}
1.0 0.0015
= 0.1306.
1.0 0.0015 + 0.01 0.9985
In other words, even though our test is quite reliable, there is such a low
prior probability of having been infected with AIDS that there is not much
evidence to accept the hypothesis even after this test.
19
test 1
age
x
test 2
Fig. 1.13. A graphical description of our HIV testing scenario. Knowing the age of
the patient influences our prior on whether the patient is HIV positive (the random
variable X). The outcomes of the tests 1 and 2 are independent of each other given
the status X. We observe the shaded random variables (age, test 1, test 2) and
would like to infer the un-shaded random variable X. This is a special case of a
graphical model which we will discuss in Chapter ??.
Let us now think how we could improve the diagnosis. One way is to obtain further information about the patient and to use this in the diagnosis.
For instance, information about his age is quite useful. Suppose the patient
is 35 years old. In this case we would want to compute p(X = HIV+|T =
HIV+, A = 35) where the random variable A denotes the age. The corresponding expression yields:
p(T = HIV+|X = HIV+, A)p(X = HIV+|A)
p(T = HIV+|A)
Here we simply conditioned all random variables on A in order to take additional information into account. We may assume that the test is independent
of the age of the patient, i.e.
p(t|x, a) = p(t|x).
What remains therefore is p(X = HIV+|A). Recent US census data pegs this
number at approximately 0.9%. Plugging all data back into the conditional
10.009
expression yields 10.009+0.010.991
= 0.48. What has happened here is that
by including additional observed random variables our estimate has become
more reliable. Combination of evidence is a powerful tool. In our case it
helped us make the classification problem of whether the patient is HIVpositive or not more reliable.
A second tool in our arsenal is the use of multiple measurements. After
the first test the physician is likely to carry out a second test to confirm the
diagnosis. We denote by T1 and T2 (and t1 , t2 respectively) the two tests.
Obviously, what we want is that T2 will give us an independent second
opinion of the situation. In other words, we want to ensure that T2 does
not make the same mistakes as T1 . For instance, it is probably a bad idea
to repeat T1 without changes, since it might perform the same diagnostic
20
1 Introduction
(1.16)
See Figure 1.13 for a graphical illustration of the setting. Random variables
satisfying the condition (1.16) are commonly referred to as conditionally
independent. In shorthand we write T1 , T2
X. For the sake of the argument
we assume that the statistics for T2 are given by
p(t2 |x)
x = HIV-
x = HIV+
t2 = HIV0.95
0.01
t2 = HIV+ 0.05
0.99
Clearly this test is less reliable than the first one. However, we may now
combine both estimates to obtain a very reliable estimate based on the
combination of both events. For instance, for t1 = t2 = HIV+ we have
1.0 0.99 0.009
= 0.95.
1.0 0.99 0.009 + 0.01 0.05 0.991
In other words, by combining two tests we can now confirm with very high
confidence that the patient is indeed diseased. What we have carried out is a
combination of evidence. Strong experimental evidence of two positive tests
effectively overcame an initially very strong prior which suggested that the
patient might be healthy.
Tests such as in the example we just discussed are fairly common. For
instance, we might need to decide which manufacturing procedure is preferable, which choice of parameters will give better results in a regression estimator, or whether to administer a certain drug. Note that often our tests
may not be conditionally independent and we would need to take this into
account.
p(X = HIV+|T1 = HIV+, T2 = HIV+) =
21
the
quick
brown
fox
jumped
over
lazy
dog
hunts
2
1
1
0
1
0
1
1
1
0
1
0
1
0
1
1
0
1
0
1
and associated labels yi , denoted by Y := {y1 , . . . , ym }. Here the labels satisfy yi {spam, ham}. The key assumption we make here is that the pairs
(xi , yi ) are drawn jointly from some distribution p(x, y) which represents
the e-mail generating process for a user. Moreover, we assume that there
is sufficiently strong dependence between x and y that we will be able to
estimate y given x and a set of labeled instances X, Y.
Before we do so we need to address the fact that e-mails such as Figure 1.14
are text, whereas the three algorithms we present will require data to be
represented in a vectorial fashion. One way of converting text into a vector
is by using the so-called bag of words representation [Mar61, Lew98]. In its
simplest version it works as follows: Assume we have a list of all possible
words occurring in X, that is a dictionary, then we are able to assign a unique
number with each of those words (e.g. the position in the dictionary). Now
we may simply count for each document xi the number of times a given
word j is occurring. This is then used as the value of the j-th coordinate
of xi . Figure 1.15 gives an example of such a representation. Once we have
the latter it is easy to compute distances, similarities, and other statistics
directly from the vectorial representation.
22
1 Introduction
p(x|y)p(y)
.
p(x)
We may have a good estimate of p(y), that is, the probability of receiving
a spam or ham mail. Denote by mham and mspam the number of ham and
spam e-mails in X. In this case we can estimate
mspam
mham
p(ham)
and p(spam)
.
m
m
The key problem, however, is that we do not know p(x|y) or p(x). We may
dispose of the requirement of knowing p(x) by settling for a likelihood ratio
L(x) :=
p(x|spam)p(spam)
p(spam|x)
=
.
p(ham|x)
p(x|ham)p(ham)
(1.17)
p(wj |y),
p(x|y) =
(1.18)
j=1
where wj denotes the j-th word in document x. This amounts to the assumption that the probability of occurrence of a word in a document is
independent of all other words given the category of the document. Even
though this assumption does not hold in general for instance, the word
York is much more likely to after the word New it suffices for our
purposes (see Figure 1.16).
This assumption reduces the difficulty of knowing p(x|y) to that of estimating the probabilities of occurrence of individual words w. Estimates for
23
word 1
word 2
word 3
...
word n
Fig. 1.16. Naive Bayes model. The occurrence of individual words is independent
of each other, given the category of the text. For instance, the word Viagra is fairly
frequent if y = spam but it is considerably less frequent if y = ham, except when
considering the mailbox of a Pfizer sales representative.
p(w|y) can be obtained, for instance, by simply counting the frequency occurrence of the word within documents of a given class. That is, we estimate
p(w|spam)
m
i=1
# of words in xi
j=1
m
i=1
# of words in xi
j=1
{yi = spam}
24
1 Introduction
25
Fig. 1.17. 1 nearest neighbor classifier. Depending on whether the query point x is
closest to the star, diamond or triangles, it uses one of the three labels for it.
Fig. 1.18. k-Nearest neighbor classifiers using Euclidean distances. Left: decision
boundaries obtained from a 1-nearest neighbor classifier. Middle: color-coded sets
of where the number of red / blue points ranges between 7 and 0. Right: decision
boundary determining where the blue or red dots are in the majority.
26
1 Introduction
Fig. 1.19. k-Nearest neighbor regression estimator using Euclidean distances. Left:
some points (x, y) drawn from a joint distribution. Middle: 1-nearest neighbour
classifier. Right: 7-nearest neighbour classifier. Note that the regression estimate is
much more smooth.
with a good distance measure. For instance, the technology underlying the
Netflix progress prize [BK07] was essentially nearest neighbours based.
Algorithm 1.2 k-Nearest Neighbor Classification
Classify(X, Y, x) {reads documents X, labels Y and query x}
for i = 1 to m do
Compute distance d(xi , x)
end for
Compute set I containing indices for the k smallest distances d(xi , x).
return majority label of {yi where i I}.
Note that it is trivial to extend the algorithm to regression. All we need
to change in Algorithm 1.2 is to return the average of the values yi instead
of their majority vote. Figure 1.19 has an example.
Note that the distance computation d(xi , x) for all observations can become extremely costly, in particular whenever the number of observations is
large or whenever the observations xi live in a very high dimensional space.
Random projections are a technique that can alleviate the high computational cost of Nearest Neighbor classifiers. A celebrated lemma by Johnson
and Lindenstrauss [DG03] asserts that a set of m points in high dimensional
Euclidean space can be projected into a O(log m/ 2 ) dimensional Euclidean
space such that the distance between any two points changes only by a factor of (1 ). Since Euclidean distances are preserved, running the Nearest
Neighbor classifier on this mapped data yields the same results but at a
lower computational cost [GIM99].
The surprising fact is that the projection relies on a simple randomized
algorithm: to obtain a d-dimensional representation of n-dimensional random observations we pick a matrix R Rdn where each element is drawn
27
w
x
1
m
xi and + :=
yi =1
1
m
xi .
yi =1
+ x
2 , x and
(1.19)
+ x
= +
+ x
2 + , x .
(1.20)
Here , denotes the standard dot product between vectors. Taking differences between the two distances yields
f (x) := + x
= 2 + , x +
.
(1.21)
This is a linear function in x and its sign corresponds to the labels we estimate for x. Our algorithm sports an important property: The classification
28
1 Introduction
H
x
(x)
Fig. 1.21. The feature map maps observations x from X into a feature space H.
The map is a convenient way of encoding pre-processing steps systematically.
= + , + = m2
+
xi , xj and + , x = m1
+
yi =yj =1
xi , x .
yi =1
Analogous expressions can be computed for . Consequently we may express the classification rule (1.21) as
m
f (x) =
i xi , x + b
(1.22)
i=1
2
where b = m2
k(x, x ) := (x), (x ) .
(1.23)
29
f (x) =
i k(xi , x) + b
(1.24)
i=1
1.3.4 Perceptron
In the previous sections we assumed that our classifier had access to a training set of spam and non-spam emails. In real life, such a set might be difficult
to obtain all at once. Instead, a user might want to have instant results whenever a new e-mail arrives and he would like the system to learn immediately
from any corrections to mistakes the system makes.
To overcome both these difficulties one could envisage working with the
following protocol: As emails arrive our algorithm classifies them as spam or
non-spam, and the user provides feedback as to whether the classification is
correct or incorrect. This feedback is then used to improve the performance
of the classifier over a period of time.
This intuition can be formalized as follows: Our classifier maintains a
parameter vector. At the t-th time instance it receives a data point xt , to
which it assigns a label yt using its current parameter vector. The true label
yt is then revealed, and used to update the parameter vector of the classifier.
Such algorithms are said to be online. We will now describe perhaps the
simplest classifier of this kind namely the Perceptron [Heb49, Ros58].
Let us assume that the data points xt Rd , and labels yt {1}. As
before we represent an email as a bag-of-words vector and we assign +1 to
spam emails and 1 to non-spam emails. The Perceptron maintains a weight
30
1 Introduction
w*
xt
wt+1
w*
xt
wt
Fig. 1.22. The Perceptron without bias. Left: at time t we have a weight vector wt
denoted by the dashed arrow with corresponding separating plane (also dashed).
For reference we include the linear separator w and its separating plane (both
denoted by a solid line). As a new observation xt arrives which happens to be
mis-classified by the current weight vector wt we perform an update. Also note the
margin between the point xt and the separating hyperplane defined by w . Right:
This leads to the weight vector wt+1 which is more aligned with w .
(1.25)
where w, xt denotes the usual Euclidean dot product and b is an offset. Note
the similarity of (1.25) to (1.21) of the simple classifier. Just as the latter,
the Perceptron is a linear classifier which separates its domain Rd into two
halfspaces, namely {x| w, x + b > 0} and its complement. If yt = yt then
no updates are made. On the other hand, if yt = yt the weight vector is
updated as
w w + yt xt and b b + yt .
(1.26)
Figure 1.22 shows an update step of the Perceptron algorithm. For simplicity
31
we illustrate the case without bias, that is, where b = 0 and where it remains
unchanged. A detailed description of the algorithm is given in Algorithm 1.3.
An important property of the algorithm is that it performs updates on w
by multiples of the observations xi on which it makes a mistake. Hence we
may express w as w = iError yi xi . Just as before, we can replace xi and x
by (xi ) and (x) to obtain a kernelized version of the Perceptron algorithm
[FS99] (Algorithm 1.4).
If the dataset (X, Y) is linearly separable, then the Perceptron algorithm
eventually converges and correctly classifies all the points in X. The rate of
convergence however depends on the margin. Roughly speaking, the margin
quantifies how linearly separable a dataset is, and hence how easy it is to
solve a given classification problem.
Definition 1.6 (Margin) Let w Rd be a weight vector and let b R be
an offset. The margin of an observation x Rd with associated label y is
(x, y) := y ( w, x + b) .
(1.27)
(1.28)
Geometrically speaking (see Figure 1.22) the margin measures the distance
of x from the hyperplane defined by {x| w, x + b = 0}. Larger the margin,
the more well separated the data and hence easier it is to find a hyperplane
with correctly classifies the dataset. The following theorem asserts that if
there exists a linear classifier which can classify a dataset with a large margin, then the Perceptron will also correctly classify the same dataset after
making a small number of mistakes.
Theorem 1.7 (Novikoff s theorem) Let (X, Y) be a dataset with at least
one example labeled +1 and one example labeled 1. Let R := maxt xt , and
assume that there exists (w , b ) such that w = 1 and t := yt ( w , xt +
2
)2 )
b ) for all t. Then, the Perceptron will make at most (1+R )(1+(b
2
mistakes.
This result is remarkable since it does not depend on the dimensionality
of the problem. Instead, it only depends on the geometry of the setting,
as quantified via the margin and the radius R of a ball enclosing the
observations. Interestingly, a similar bound can be shown for Support Vector
Machines [Vap95] which we will be discussing in Chapter 8.
Proof We can safely ignore the iterations where no mistakes were made
32
1 Introduction
and hence no updates were carried out. Therefore, without loss of generality
assume that the t-th update was made after seeing the t-th observation and
let wt denote the weight vector after the update. Furthermore, for simplicity
assume that the algorithm started with w0 = 0 and b0 = 0. By the update
equation (1.26) we have
wt , w + bt b = wt1 , w + bt1 b + yt ( xt , w + b )
wt1 , w + bt1 b + .
By induction it follows that wt , w +bt b t. On the other hand we made
an update because yt ( xt , wt1 + bt1 ) < 0. By using yt yt = 1,
wt
+ b2t = wt1
+ b2t1 + yt2 xt
wt1
+ b2t1 + xt
+1
wt
bt
t(R2 + 1)
w
b
wt
bt
=
,
wt
w
b
2
+ b2t
1 + (b )2
1 + (b )2 .
Squaring both sides of the inequality and rearranging the terms yields an
upper bound on the number of updates and hence the number of mistakes.
The Perceptron was the building block of research on Neural Networks
[Hay98, Bis95]. The key insight was to combine large numbers of such networks, often in a cascading fashion, to larger objects and to fashion optimization algorithms which would lead to classifiers with desirable properties.
In this book we will take a complementary route. Instead of increasing the
number of nodes we will investigate what happens when increasing the complexity of the feature map and its associated kernel k. The advantage of
doing so is that we will reap the benefits from convex analysis and linear
models, possibly at the expense of a slightly more costly function evaluation.
1.3.5 K-Means
All the algorithms we discussed so far are supervised, that is, they assume
that labeled training data is available. In many applications this is too much
33
to hope for; labeling may be expensive, error prone, or sometimes impossible. For instance, it is very easy to crawl and collect every page within the
www.purdue.edu domain, but rather time consuming to assign a topic to
each page based on its contents. In such cases, one has to resort to unsupervised learning. A prototypical unsupervised learning algorithm is K-means,
which is clustering algorithm. Given X = {x1 , . . . , xm } the goal of K-means
is to partition it into k clusters such that each point in a cluster is similar
to points from its own cluster than with points from some other cluster.
Towards this end, define prototype vectors 1 , . . . , k and an indicator
vector rij which is 1 if, and only if, xi is assigned to cluster j. To cluster our
dataset we will minimize the following distortion measure, which minimizes
the distance of each point from the prototype vector:
1
J(r, ) :=
2
rij xi j
(1.29)
i=1 j=1
(1.30)
and 0 otherwise.
Stage 2 Keep the r fixed and determine . Since the rs are fixed, J is an
quadratic function of . It can be minimized by setting the derivative
with respect to j to be 0:
m
(1.31)
i=1
Rearranging obtains
j =
i rij xi
i rij
(1.32)
34
1 Introduction
The algorithm stops when the cluster assignments do not change significantly. Detailed pseudo-code can be found in Algorithm 3.2.
Algorithm 1.5 K-Means
Cluster(X) {Cluster dataset X}
Initialize cluster centers j for j = 1, . . . , k randomly
repeat
for i = 1 to m do
Compute j = argminj=1,...,k d(xi , j )
Set rij = 1 and rij = 0 for all j = j
end for
for j = 1 to k doP
r xi
Compute j = Pi ij
i rij
end for
until Cluster assignments rij are unchanged
return {1 , . . . , k } and rij
Two issues with K-Means are worth noting. First, it is sensitive to the
choice of the initial cluster centers . A number of practical heuristics have
been developed. For instance, one could randomly choose k points from the
given dataset as cluster centers. Other methods try to pick k points from X
which are farthest away from each other. Second, it makes a hard assignment
of every point to a cluster center. Variants which we will encounter later in
the book will relax this. Instead of letting rij {0, 1} these soft variants
will replace it with the probability that a given xi belongs to cluster j.
The K-Means algorithm concludes our discussion of a set of basic machine
learning methods for classification and regression. They provide a useful
starting point for an aspiring machine learning researcher. In this book we
will see many more such algorithms as well as connections between these
basic algorithms and their more advanced counterparts.
Problems
Problem 1.1 (Eyewitness) Assume that an eyewitness is 90% certain
that a given person committed a crime in a bar. Moreover, assume that
there were 50 people in the restaurant at the time of the crime. What is the
posterior probability of the person actually having committed the crime.
Problem 1.2 (DNA Test) Assume the police have a DNA library of 10
million records. Moreover, assume that the false recognition probability is
35
below 0.00001% per record. Suppose a match is found after a database search
for an individual. What are the chances that the identification is correct? You
can assume that the total population is 100 million people. Hint: compute
the probability of no match occurring first.
Problem 1.3 (Bomb Threat) Suppose that the probability that one of a
thousand passengers on a plane has a bomb is 1 : 1, 000, 000. Assuming that
the probability to have a bomb is evenly distributed among the passengers,
the probability that two passengers have a bomb is roughly equal to 1012 .
Therefore, one might decide to take a bomb on a plane to decrease chances
that somebody else has a bomb. What is wrong with this argument?
Problem 1.4 (Monty-Hall Problem) Assume that in a TV show the
candidate is given the choice between three doors. Behind two of the doors
there is a pencil and behind one there is the grand prize, a car. The candidate chooses one door. After that, the showmaster opens another door behind
which there is a pencil. Should the candidate switch doors after that? What
is the probability of winning the car?
Problem 1.5 (Mean and Variance for Random Variables) Denote by
Xi random variables. Prove that in this case
EX1 ,...XN
xi =
i
xi =
i
VarXi [xi ]
i
36
1 Introduction
1
(1 + x2 )
(1.33)
mean and variance are undefined. Hint: show that the integral diverges.
Problem 1.11 (Quantiles) Find a distribution for which the mean exceeds the median. Hint: the mean depends on the value of the high-quantile
terms, whereas the median does not.
Problem 1.12 (Multicategory Naive Bayes) Prove that for multicategory Naive Bayes the optimal decision is given by
n
p([x]i |y)
(1.34)
i=1
2
Density Estimation
Pr(X 11) =
11
p(i) =
i=0
i=0
100
i
1
6
5
6
100i
7.0%
(2.1)
After looking at this figure you decide that things are probably reasonable.
And, in fact, they are consistent with the convergence behavior of a simulated dice in Figure 2.1. In computing (2.1) we have learned something
useful: the expansion is a special case of a binomial series. The first term
m=10
m=20
m=50
m=100
m=200
m=500
0.3
0.3
0.3
0.3
0.3
0.3
0.2
0.2
0.2
0.2
0.2
0.2
0.1
0.1
0.1
0.1
0.1
0.1
0.0
1234 56
0.0
1234 56
0.0
1234 56
0.0
1234 56
0.0
1234 56
0.0
1234 56
Fig. 2.1. Convergence of empirical means to expectations. From left to right: empirical frequencies of occurrence obtained by casting a dice 10, 20, 50, 100, 200, and
500 times respectively. Note that after 20 throws we still have not observed a single
20
6, an event which occurs with only 56
2.6% probability.
37
38
2 Density Estimation
Xi
(2.2)
i=1
be the empirical average over the random variables Xi . Then for any
the following holds
>0
m
lim Pr X
(2.3)
= 1.
39
6
5
4
3
2
1
101
102
103
Fig. 2.2. The mean of a number of casts of a dice. The horizontal straight line
n as a
denotes the mean 3.5. The uneven solid line denotes the actual mean X
function of the number of draws, given as a semilogarithmic plot. The crosses denote
n ever more closely approaches the mean 3.5
the outcomes of the dice. Note how X
are we obtain an increasing number of observations.
This establishes that, indeed, for large enough sample sizes, the average will
converge to the expectation. The strong law strengthens this as follows:
Theorem 2.2 (Strong Law of Large Numbers) Under the conditions
m = = 1.
of Theorem 2.1 we have Pr limm X
m
The strong law implies that almost surely (in a measure theoretic sense) X
converges to , whereas the weak law only states that for every the random
m will be within the interval [ , + ]. Clearly the strong implies
variable X
m = converges to 1, hence
the weak law since the measure of the events X
any -ball around would capture this.
Both laws justify that we may take sample averages, e.g. over a number
of events such as the outcomes of a dice and use the latter to estimate their
means, their probabilities (here we treat the indicator variable of the event
as a {0; 1}-valued random variable), their variances or related quantities. We
postpone a proof until Section 2.1.2, since an effective way of proving Theorem 2.1 relies on the theory of characteristic functions which we will discuss
in the next section. For the moment, we only give a pictorial illustration in
Figure 2.2.
m = m1 m Xi conOnce we established that the random variable X
i=1
verges to its mean , a natural second question is to establish how quickly it
m are.
converges and what the properties of the limiting distribution of X
Note in Figure 2.2 that the initial deviation from the mean is large whereas
as we observe more data the empirical mean approaches the true one.
40
2 Density Estimation
6
5
4
3
2
1
101
102
103
Fig. 2.3. Five instantiations of a running average over outcomes of a toss of a dice.
Note that all of them converge to the mean 3.5. Moreover note that they all are
well contained within the upper and lower envelopes given by VarX [x]/m.
i2
Zm :=
i=1
Xi i
(2.4)
i=1
41
which have all mean = 3.5 and variance (see Problem 2.1)
VarX [x] = EX [x2 ] EX [x]2 = (1 + 4 + 9 + 16 + 25 + 36)/6 3.52 2.92.
We now study the random variable Wm := m1 m
i=1 [Xi 3.5]. Since each
of the terms in the sum has zero mean, also Wm s mean vanishes. Moreover,
Wm is a multiple of Zm of (2.4). Hence we have that Wm converges to a
1
normal distribution with zero mean and standard deviation 2.92m 2 .
Consequently the average of m tosses of the dice yields a random variable with mean 3.5 and it will approach a normal distribution with variance
1
m 2 2.92. In other words, the empirical mean converges to its average at
1
rate O(m 2 ). Figure 2.3 gives an illustration of the quality of the bounds
implied by the CLT.
One remarkable property of functions of random variables is that in many
conditions convergence properties of the random variables are bestowed upon
the functions, too. This is manifest in the following two results: a variant
of Slutskys theorem and the so-called delta method. The former deals with
limit behavior whereas the latter deals with an extension of the central limit
theorem.
Theorem 2.4 (Slutskys Theorem) Denote by Xi , Yi sequences of random variables with Xi X and Yi c for c R in probability. Moreover,
denote by g(x, y) a function which is continuous for all (x, c). In this case
the random variable g(Xi , Yi ) converges in probability to g(X, c).
For a proof see e.g. [Bil68]. Theorem 2.4 is often referred to as the continuous
mapping theorem (Slutsky only proved the result for affine functions). It
means that for functions of random variables it is possible to pull the limiting
procedure into the function. Such a device is useful when trying to prove
asymptotic normality and in order to obtain characterizations of the limiting
distribution.
Theorem 2.5 (Delta Method) Assume that Xn Rd is asymptotically
2
normal with a2
n (Xn b) N(0, ) for an 0. Moreover, assume that
d
l
g : R R is a mapping which is continuously differentiable at b. In this
case the random variable g(Xn ) converges
a2
n (g(Xn ) g(b)) N(0, [x g(b)][x g(b)] ).
(2.5)
(2.6)
42
2 Density Estimation
F [f ]() := (2) 2
(2.7)
(2.8)
Rn
d
F 1 [g](x) := (2) 2
Rn
43
X () := (2) 2 F 1 [p(x)] =
exp(i , x )dp(x).
(2.9)
In other words, X () is the inverse Fourier transform applied to the probability measure p(x). Consequently X () uniquely characterizes p(x) and
moreover, p(x) can be recovered from X () via the forward Fourier transform. One of the key utilities of characteristic functions that they allow us
to deal in easy ways with sums of random variables.
Theorem 2.8 (Sums of random variables and convolutions) Denote
by X, Y R two independent random variables. Moreover, denote by Z :=
X + Y the sum of both random variables. Then the distribution over Z satisfies p(z) = p(x) p(y). Moreover, the characteristic function yields:
Z () = X ()Y ().
(2.10)
The result for characteristic functions follows form the property of the
Fourier transform.
For sums of several random variables the characteristic function is the product of the individual characteristic functions. This allows us to prove both
the weak law of large numbers and the central limit theorem (see Figure 2.4
for an illustration) by proving convergence in the Fourier domain.
Proof [Weak Law of Large Numbers] At the heart of our analysis lies
a Taylor expansion of the exponential into
exp(iwx) = 1 + i w, x + o(|w|)
and hence X () = 1 + iwEX [x] + o(|w|).
1
44
2 Density Estimation
1.0
1.0
1.0
1.0
1.0
0.5
0.5
0.5
0.5
0.5
0.0
-5
0.0
-5
0.0
-5
0.0
-5
0.0
1.5
1.5
1.5
1.5
1.5
1.0
1.0
1.0
1.0
1.0
0.5
0.5
0.5
0.5
0.5
0.0
-1 0
0.0
-1 0
0.0
-1 0
0.0
-1 0
0.0
-5
-1 0
Fig. 2.4. A working example of the central limit theorem. The top row contains
distributions of sums of uniformly distributed random variables on the interval
[0.5, 0.5]. From left to right we have sums of 1, 2, 4, 8 and 16 random variables.
The
bottom row contains the same distribution with the means rescaled by m, where
m is the number of observations. Note how the distribution converges increasingly
to the normal distribution.
Given m random variables Xi with mean EX [x] = this means that their
m := 1 m Xi has the characteristic function
average X
i=1
m
X m () =
1+
i
w + o(m1 |w|)
m
(2.11)
In the limit of m this converges to exp(iw), the characteristic function of the constant distribution with mean . This proves the claim that in
m is essentially constant with mean .
the large sample limit X
Proof [Central Limit Theorem] We use the same idea as above to prove
the CLT. The main difference, though, is that we need to assume that the
second moments of the random variables Xi exist. To avoid clutter we only
prove the case of constant mean EXi [xi ] = and variance VarXi [xi ] = 2 .
45
Let Zm := 1 2 m
i=1 (Xi ). Our proof relies on showing convergence
m
of the characteristic function of Zm , i.e. Zm to that of a normally distributed random variable W with zero mean and unit variance. Expanding
the exponential to second order yields:
1
exp(iwx) = 1 + iwx w2 x2 + o(|w|2 )
2
1
and hence X () = 1 + iwEX [x] w2 VarX [x] + o(|w|2 )
2
Since the mean of Zm vanishes by centering (Xi ) and the variance per
variable is m1 we may write the characteristic function of Zm via
Zm () =
1 2
1
w + o(m1 |w|2 )
2m
(2.12)
Its proof is left as an exercise. See Problem 2.2 for details. This connection
also implies (subject to regularity conditions) that if we know the moments
of a distribution we are able to reconstruct it directly since it allows us
to reconstruct its characteristic function. This idea has been exploited in
density estimation [Cra46] in the form of Edgeworth and Gram-Charlier
expansions [Hal92].
46
2 Density Estimation
Pr(X ) .
(2.13)
Proof We use the fact that for nonnegative random variables
Pr(X ) =
dp(x)
dp(x)
xdp(x) =
This means that for random variables with a small mean, the proportion of
samples with large value has to be small.
Consequently deviations from the mean are O( 1 ). However, note that this
bound does not depend on the number of observations. A useful application
of the Gauss-Markov inequality is Chebyshevs inequality. It is a statement
on the range of random variables using its variance.
Theorem 2.10 (Chebyshev) Denote by X a random variable with mean
and variance 2 . Then the following holds for > 0:
Pr(|x | )
2
2
(2.14)
m2 VarXi [xi ] = m1 2 .
VarX m [
xm ] =
i=1
47
2 m1 2 and equivalently / m.
This bound is quite reasonable for large but it means that for high levels
of confidence we need a huge number of observations.
Much stronger results can be obtained if we are able to bound the range
of the random variables. Using the latter, we reap an exponential improvement in the quality of the bounds in the form of the McDiarmid [McD89]
inequality. We state the latter without proof:
Theorem 2.11 (McDiarmid) Denote by f : Xm R a function on X
and let Xi be independent random variables. In this case the following holds:
Pr (|f (x1 , . . . , xm ) EX1 ,...,Xm [f (x1 , . . . , xm )]| > ) 2 exp 2 2 C 2 .
Here the constant C 2 is given by C 2 =
m
2
i=1 ci
where
f (x1 , . . . , xi , . . . , xm ) f (x1 , . . . , xi , . . . , xm ) ci
for all x1 , . . . , xm , xi and for all i.
This bound can be used for averages of a number of observations when
they are computed according to some algorithm as long as the latter can be
encoded in f . In particular, we have the following bound [Hoe63]:
Theorem 2.12 (Hoeffding) Denote by Xi iid random variables with bounded
m := m1 m Xi be their average.
range Xi [a, b] and mean . Let X
i=1
Then the following bound holds:
m >
Pr X
2 exp
2m 2
(b a)2
(2.15)
48
2 Density Estimation
2m
2 exp (ba)
2
(2.16)
needs to satisfy
(2.17)
In other words, while the confidence level only enters logarithmically into the
1
inequality, the sample size m improves our confidence only with = O(m 2 ).
That is, in order to improve our confidence interval from = 0.1 to = 0.01
we need 100 times as many observations.
While this bound is tight (see Problem 2.5 for details), it is possible to obtain better bounds if we know additional information. In particular knowing
a bound on the variance of a random variable in addition to knowing that it
has bounded range would allow us to strengthen the statement considerably.
The Bernstein inequality captures this connection. For details see [BBL05]
or works on empirical process theory [vdVW96, SW86, Vap82].
2.1.4 An Example
It is probably easiest to illustrate the various bounds using a concrete example. In a semiconductor fab processors are produced on a wafer. A typical
300mm wafer holds about 400 chips. A large number of processing steps
are required to produce a finished microprocessor and often it is impossible
to assess the effect of a design decision until the finished product has been
produced.
Assume that the production manager wants to change some step from
process A to some other process B. The goal is to increase the yield of
the process, that is, the number of chips of the 400 potential chips on the
wafer which can be sold. Unfortunately this number is a random variable,
i.e. the number of working chips per wafer can vary widely between different
wafers. Since process A has been running in the factory for a very long
time we may assume that the yield is well known, say it is A = 350 out
of 400 processors on average. It is our goal to determine whether process
B is better and what its yield may be. Obviously, since production runs
are expensive we want to be able to determine this number as quickly as
possible, i.e. using as few wafers as possible. The production manager is risk
averse and wants to ensure that the new process is really better. Hence he
requires a confidence level of 95% before he will change the production.
49
(2.18)
we can solve for m = 2 / 2 = 40, 000/(0.05 400) = 20, 000. In other words,
we would typically need 20,000 wafers to assess with reasonable confidence
whether process B is better than process A. This is completely unrealistic.
Slightly better bounds can be obtained if we are able to make better
assumptions on the variance. For instance, if we can be sure that the yield
of process B is at least 300, then the largest possible variance is 0.25(300
0)2 + 0.75(300 400)2 = 30, 000, leading to a minimum of 15,000 wafers
which is not much better.
Hoeffding Since the yields are in the interval {0, . . . , 400} we have an explicit bound on the range of observations. Recall the inequality (2.16) which
bounds the failure probably = 0.05 by an exponential term. Solving this
for m yields
m 0.5|b a|2
log(2/) 737.8
(2.19)
50
2 Density Estimation
exp
(x )2
2 2
dx = 0.95
(2.20)
2
= 2.96/ m and hence m = 8.76 2
(2.21)
Again, our problem is that we do not know the variance of the distribution.
Using the worst-case bound on the variance, i.e. 2 = 40, 000 would lead to
a requirement of at least m = 876 wafers for testing. However, while we do
not know the variance, we may estimate it along with the mean and use the
empirical estimate, possibly plus some small constant to ensure we do not
underestimate the variance, instead of the upper bound.
Assuming that fluctuations turn out to be in the order of 50 processors,
i.e. 2 = 2500, we are able to reduce our requirement to approximately 55
wafers. This is probably an acceptable number for a practical test.
Rates and Constants The astute reader will have noticed that all three
confidence bounds had scaling behavior m = O( 2 ). That is, in all cases
the number of observations was a fairly ill behaved function of the amount
of confidence required. If we were just interested in convergence per se, a
statement like that of the Chebyshev inequality would have been entirely
sufficient. The various laws and bounds can often be used to obtain considerably better constants for statistical confidence guarantees. For more
complex estimators, such as methods to classify, rank, or annotate data,
a reasoning such as the one above can become highly nontrivial. See e.g.
[MYA94, Vap98] for further details.
51
(2.22)
m
1
where pX (x) := m
(2.23)
i=1
10
11
12
Occurrences of dog
This means that the word dog occurs the following number of times:
Occurrences of dog
Number of documents
pX (x) := (m + |X|)1 1 +
{xi = x} = p(x)
(2.24)
i=1
52
2 Density Estimation
Occurrences of dog
Number of documents
Frequency of occurrence
Laplace smoothing
4
0.33
0.26
2
0.17
0.16
2
0.17
0.16
1
0.083
0.11
1
0.083
0.11
0
0
0.05
2
0.17
0.16
The problem with this method is that as |X| increases we need increasingly
more observations to obtain even a modicum of precision. On average, we
will need at least one observation for every x X. This can be infeasible for
large domains as the following example shows.
Example 2.4 (Curse of Dimensionality) Assume that X = {0, 1}d , i.e.
x consists of binary bit vectors of dimensionality d. As d increases the size of
X increases exponentially, requiring an exponential number of observations
to perform density estimation. For instance, if we work with images, a 100
100 black and white picture would require in the order of 103010 observations
to model such fairly low-resolution images accurately. This is clearly utterly
infeasible the number of particles in the known universe is in the order
of 1080 . Bellman [Bel61] was one of the first to formalize this dilemma by
coining the term curse of dimensionality.
This example clearly shows that we need better tools to deal with highdimensional data. We will present one of such tools in the next section.
1
m
(x xi )
i=1
(2.25)
53
we may choose to smooth it out by a smoothing kernel h(x) such that the
probability mass becomes somewhat more spread out. For a density estimate
on X Rd this is achieved by
p(x) =
1
m
rd h
xxi
r
(2.26)
i=1
q=
R
Out of the m samples drawn from p(x), the probability that k of them fall
in region R is given by the binomial distribution
m k
q (1 q)mk .
k
The expected fraction of points falling inside the region can easily be computed from the expected value of the Binomial distribution: E[k/m] = q.
Similarly, the variance can be computed as Var[k/m] = q(1 q)/m. As
m the variance goes to 0 and hence the estimate peaks around the
expectation. We can therefore set
k mq.
If we assume that R is so small that p(x) is constant over R, then
q p(x) V,
where V is the volume of R. Rearranging we obtain
p(x)
k
.
mV
(2.27)
Let us now set R to be a cube with side length r, and define a function
h(u) =
Observe that h
xxi
r
1 if |ui |
1
2
0 otherwise.
54
2 Density Estimation
around x. If we let
m
k=
h
i=1
x xi
r
rd h
i=1
x xi
h
where rd is the volume of the hypercube of size r in d dimensions. By symmetry, we can interpret this equation as the sum over m cubes centered around
m data points xn . If we replace the cube by any smooth kernel function h()
this recovers (2.26).
There exists a large variety of different kernels which can be used for the
kernel density estimate. [Sil86] has a detailed description of the properties
of a number of kernels. Popular choices are
1
1 2
h(x) = (2) 2 e 2 x
h(x) =
h(x) =
h(x) =
1 |x|
2e
3
4 max(0, 1
1
2 [1,1] (x)
x )
Gaussian kernel
(2.28)
Laplace kernel
(2.29)
Epanechnikov kernel
(2.30)
Uniform kernel
(2.31)
Triangle kernel.
(2.32)
Further kernels are the triweight and the quartic kernel which are basically
powers of the Epanechnikov kernel. For practical purposes the Gaussian kernel (2.28) or the Epanechnikov kernel (2.30) are most suitable. In particular,
the latter has the attractive property of compact support. This means that
for any given density estimate at location x we will only need to evaluate
terms h(xi x) for which the distance xi x is less than r. Such expansions are computationally much cheaper, in particular when we make use of
fast nearest neighbor search algorithms [GIM99, IM98]. Figure 2.7 has some
examples of kernels.
2.2.3 Parameter Estimation
So far we have not discussed the issue of parameter selection. It should be
evident from Figure 2.6, though, that it is quite crucial to choose a good
kernel width. Clearly, a kernel that is overly wide will oversmooth any fine
detail that there might be in the density. On the other hand, a very narrow
kernel will not be very useful, since it will be able to make statements only
about the locations where we actually observed data.
55
0.10
0.05
0.04
0.03
0.05
0.02
0.01
0.00
40
50
60
70
80
90
100
0.00
40
110
50
60
70
80
90
100
110
Fig. 2.5. Left: a naive density estimate given a sample of the weight of 18 persons.
Right: the underlying weight distribution.
0.050
0.050
0.050
0.050
0.025
0.025
0.025
0.025
0.000
40
60
80 100
0.000
40
60
80 100
0.000
40
60
80 100
0.000
40
60
80 100
Fig. 2.6. Parzen windows density estimate associated with the 18 observations of
the Figure above. From left to right: Gaussian kernel density estimate with kernel
of width 0.3, 1, 3, and 10 respectively.
1.0
1.0
1.0
1.0
0.5
0.5
0.5
0.5
0.0
-2 -1 0 1 2
0.0
-2 -1 0 1 2
0.0
-2 -1 0 1 2
0.0
-2 -1 0 1 2
Fig. 2.7. Some kernels for Parzen windows density estimation. From left to right:
Gaussian kernel, Laplace kernel, Epanechikov kernel, and uniform density.
56
2 Density Estimation
p(xi ) = m log m +
log
i=1
rd h
log
i=1
xi xj
r
(2.33)
j=1
Remark 2.13 (Log-likelihood) We consider the logarithm of the likelihood for reasons of computational stability to prevent numerical underflow.
While each term p(xi ) might be within a suitable range, say 102 , the product of 1000 of such terms will easily exceed the exponent of floating point
representations on a computer. Summing over the logarithm, on the other
hand, is perfectly feasible even for large numbers of observations.
Unfortunately computing the log-likelihood is equally infeasible: for decreasing r the only surviving terms in (2.33) are the functions h((xi xi )/r) =
h(0), since the arguments of all other kernel functions diverge. In other
words, the log-likelihood is maximized when p(x) is peaked exactly at the
locations where we observed the data. The graph on the left of Figure 2.6
shows what happens in such a situation.
What we just experienced is a case of overfitting where our model is too
flexible. This led to a situation where our model was able to explain the
observed data unreasonably well, simply because we were able to adjust
our parameters given the data. We will encounter this situation throughout
the book. There exist a number of ways to address this problem.
Validation Set: We could use a subset of our set of observations as an
estimate of the log-likelihood. That is, we could partition the observations into X := {x1 , . . . , xn } and X := {xn+1 , . . . , xm } and use
the second part for a likelihood score according to (2.33). The second
set is typically called a validation set.
n-fold Crossvalidation: Taking this idea further, note that there is no
particular reason why any given xi should belong to X or X respectively. In fact, we could use all splits of the observations into sets
X and X to infer the quality of our estimate. While this is computationally infeasible, we could decide to split the observations into
n equally sized subsets, say X1 , . . . , Xn and use each of them as a
validation set at a time while the remainder is used to generate a
density estimate.
Typically n is chosen to be 10, in which case this procedure is
57
referred to as 10-fold crossvalidation. It is a computationally attractive procedure insofar as it does not require us to change the basic
estimation algorithm. Nonetheless, computation can be costly.
Leave-one-out Estimator: At the extreme end of crossvalidation we could
choose n = m. That is, we only remove a single observation at a time
and use the remainder of the data for the estimate. Using the average
over the likelihood scores provides us with an even more fine-grained
estimate. Denote by pi (x) the density estimate obtained by using
X := {x1 , . . . , xm } without xi . For a Parzen windows estimate this
is given by
pi (xi ) = (m 1)1
rd h
xi xj
r
m
m1
p(xi ) rd h(0) .
j=i
(2.34)
Note that this is precisely the term rd h(0) that is removed from
the estimate. It is this term which led to divergent estimates for
r 0. This means that the leave-one-out log-likelihood estimate
can be computed easily via
m
m
L(X) = m log m1
+
(2.35)
i=1
58
2 Density Estimation
Fig. 2.8. Nonuniform density. Left: original density with samples drawn from the
distribution. Middle: density estimate with a uniform kernel. Right: density estimate
using Silvermans adjustment.
1
m
rid h
xxi
ri
(2.37)
i=1
59
my
m
xi x
1
d
i:yi =y r h
my
r
m
xi x
1
d
i=1 r h
m
r
(2.38)
Here we only take the sum over all xi with label yi = y in the numerator.
The advantage of this approach is that it is very cheap to design such an
estimator. After all, we only need to compute sums. The downside, similar
to that of the k-nearest neighbor classifier is that it may require sums (or
search) over a large number of observations. That is, evaluation of (2.38) is
potentially an O(m) operation. Fast tree based representations can be used
to accelerate this [BKL06, KM00], however their behavior depends significantly on the dimensionality of the data. We will encounter computationally
more attractive methods at a later stage.
For binary classification (2.38) can be simplified considerably. Assume
that y {1}. For p(y = 1|x) > 0.5 we will choose that we should estimate
y = 1 and in the converse case we would estimate y = 1. Taking the
difference between twice the numerator and the denominator we can see
that the function
f (x) =
i yi h
ih
xi x
r
xi x
r
yi
i
xi x
r
xi x
h
i
r
=:
yi wi (x)
(2.39)
can be used to achieve the same goal since f (x) > 0 p(y = 1|x) > 0.5.
Note that f (x) is a weighted combination of the labels yi associated with
weights wi (x) which depend on the proximity of x to an observation xi .
In other words, (2.39) is a smoothed-out version of the k-nearest neighbor
classifier of Section 1.3.2. Instead of drawing a hard boundary at the k closest
observation we use a soft weighting scheme with weights wi (x) depending
on which observations are closest.
Note furthermore that the numerator of (2.39) is very similar to the simple
classifier of Section 1.3.3. In fact, for kernels k(x, x ) such as the Gaussian
RBF kernel, which are also kernels in the sense of a Parzen windows density estimate, i.e. k(x, x ) = rd h xx
the two terms are identical. This
r
60
2 Density Estimation
Fig. 2.9. Watson Nadaraya estimate. Left: a binary classifier. The optimal solution
would be a straight line since both classes were drawn from a normal distribution
with the same variance. Right: a regression estimator. The data was generated from
a sinusoid with additive noise. The regression tracks the sinusoid reasonably well.
2.3.1 Basics
Densities from the exponential family are defined by
p(x; ) := exp ( (x), g()) .
(2.40)
61
(2.41)
Example 2.5 (Binary Model) Assume that X = {0; 1} and that (x) =
x. In this case we have g() = log e0 + e = log 1 + e . It follows that
e
1
p(x = 0; ) = 1+e
and p(x = 1; ) = 1+e . In other words, by choosing
different values of one can recover different Bernoulli distributions.
One of the convenient properties of exponential families is that the logpartition function g can be used to generate moments of the distribution
itself simply by taking derivatives.
Theorem 2.14 (Log partition function) The function g() is convex.
Moreover, the distribution p(x; ) satisfies
g() = Ex [(x)] and 2 g() = Varx [(x)] .
(2.42)
Proof Note that 2 g() = Varx [(x)] implies that g is convex, since the
covariance matrix is positive semidefinite. To show (2.42) we expand
g() =
X (x) exp
(x), dx
=
X exp (x),
(2.43)
= Ex (x)(x)
Ex [(x)] Ex [(x)]
(2.44)
(2.45)
which proves the claim. For the first equality we used (2.43). For the second
line we used the definition of the variance.
One may show that higher derivatives n g() generate higher order cumulants of (x) under p(x; ). This is why g is often also referred as the
cumulant-generating function. Note that in general, computation of g()
is nontrivial since it involves solving a highdimensional integral. For many
62
2 Density Estimation
cases, in fact, the computation is NP hard, for instance when X is the domain of permutations [FJ95]. Throughout the book we will discuss a number
of approximation techniques which can be applied in such a case.
Let us briefly illustrate (2.43) using the binary model of Example 2.5.
e
e
2
We have that = 1+e
and = (1+e )2 . This is exactly what we would
have obtained from direct computation of the mean p(x = 1; ) and variance
p(x = 1; ) p(x = 1; )2 subject to the distribution p(x; ).
2.3.2 Examples
A large number of densities are members of the exponential family. Note,
however, that in statistics it is not common to express them in the dot
product formulation for historic reasons and for reasons of notational compactness. We discuss a number of common densities below and show why
they can be written in terms of an exponential family. A detailed description
of the most commonly occurring types are given in a table.
Gaussian Let x, Rd and let Rdd where
0, that is, is a
positive definite matrix. In this case the normal distribution can be
expressed via
d
1
1
p(x) = (2) 2 || 2 exp (x ) 1 (x )
(2.46)
2
1
= exp x 1 + tr xx
1 c(, )
2
(2.47)
63
n!
k
p(zn = k) =
(n k)!k! nk
=
k
k!
1
n
nk
n!
k
n (n k)!
(2.49)
1
For n the second term converges to e . The third term converges to 1, since we have a product of only 2k terms, each of which
converge to 1. Using the exponential families notation we may check
that E[x] = and that moreover also Var[x] = .
Beta This is a distribution on the unit interval X = [0, 1] which is very
versatile when it comes to modelling unimodal and bimodal distributions. It is given by
p(x) = xa1 (1 x)b1
(a + b)
.
(a)(b)
(2.50)
64
2 Density Estimation
0.40
3.5
0.35
3.0
0.30
2.5
0.25
2.0
0.20
1.5
0.15
1.0
0.10
0.5
0.05
0.00
0
10
15
20
25
30
0.0
0.0
0.2
0.4
0.6
0.8
1.0
Fig. 2.10. Left: Poisson distributions with = {1, 3, 10}. Right: Beta distributions
with a = 2 and b {1, 2, 3, 5, 7}. Note how with increasing b the distribution
becomes more peaked close to the origin.
Lebesgue
[0, )
R
Laplace
Gaussian
[0, 1]
[0, )
Cn
Sn
R+
N
Beta
Gamma
Wishart
Dirichlet
Inverse 2
Logarithmic
Conjugate
Lebesgue
1
x
( ni=1 xi )1
1
e 2x
|X|
1
x(1x)
1
x
n+1
2
x 2
Lebesgue
log (
( 1) log 2 + log( 1)
log( log(1 e ))
generic
(, g())
n
i=1 log (i )
log (1 ) 1 log 2
1 log |2 | + 1 n log 2
+ ni=1 log 1 + 1i
2
n
i=1 i )
2
1
1
1 1
2 log 2 2 log 2 + 2 2
1
n
1
1
2 log 2 2 log |2 | + 2 1 2 1
1
1
2 log 2 1 2 2 log 2
1 )(2 )
log (
(1 +2 )
(R+ )n
(0, )
(, 0)
(0, )2
R Cn
R2
(0, )2
Rn Cn
R (0, )
(, 0)
R
RN
(, 0)
R
log 1 + e
i
log N
i=1 e
log 1 e
e
log
Domain
g()
(log x1 , . . . , log xn )
log x
x
(log x, x)
log |x|, 12 x
x, 21 x2
x, 21 xx
x, x1
x
ex
x
x
(x)
Sn denotes the probability simplex in n dimensions. Cn is the cone of positive semidefinite matrices in Rnn .
[0, )
Inverse Normal
1
x!
Lebesgue
Counting
Counting
Counting
{0, 1}
{1..N }
N+
0
N+
0
Bernoulli
Multinomial
Exponential
Poisson
Measure
Domain X
Name
2.4 Estimation
65
66
2 Density Estimation
relevant steps in obtaining estimates for the special case of the exponential
family. This is done for two reasons firstly, exponential families are an
important special case and we will encounter slightly more complex variants
on the reasoning in later chapters of the book. Secondly, they are of a sufficiently simple form that we are able to show a range of different techniques.
In more advanced applications only a small subset of those methods may be
practically feasible. Hence exponential families provide us with a working
example based on which we can compare the consequences of a number of
different techniques.
(2.51)
2.4 Estimation
67
joint likelihood as
m
p(X; ) =
p(xi ; ) =
i=1
i=1
1
m
(2.52)
(2.53)
(xi ).
(2.54)
i=1
Here [X] is the empirical average of the map (x). Maximization of p(X; )
is equivalent to minimizing the negative log-likelihood log p(X; ). The
latter is a common practical choice since for independently drawn data,
the product of probabilities decomposes into the sum of the logarithms of
individual likelihoods. This leads to the following objective function to be
minimized
log p(X; ) = m [g() , [X] ]
(2.55)
xi log m.
(2.57)
i=1
Often the Poisson distribution is specified using := log as its rate parameter. In this case we
have p(x; ) = x e /x! as its parametrization. The advantage of the natural parametrization
using is that we can directly take advantage of the properties of the log-partition function as
generating the cumulants of x.
68
2 Density Estimation
ei
N
j
j=1 e
1
=
m
{xj = i} .
(2.58)
j=1
m
1
It is easy to check that (2.58) is satisfied for ei = m
j=1 {xj = i}. In other
words, the MLE for a discrete distribution simply given by the empirical
frequencies of occurrence.
The multinomial setting also exhibits two rather important aspects of exponential families: firstly, choosing i = c + log m
i=1 {xj = i} for any c R
will lead to an equivalent distribution. This is the case since the sufficient
statistic (x) is not minimal. In our context this means that the coordinates
of (x) are linearly dependent for any x we have that j [(x)]j = 1,
hence we could eliminate one dimension. This is precisely the additional
degree of freedom which is reflected in the scaling freedom in .
Secondly, for data where some events do not occur at all, the expression
m
log
j=1 {xj = i} = log 0 is ill defined. This is due to the fact that this
particular set of counts occurs on the boundary of the convex set within
which the natural parameters are well defined. We will see how different
types of priors can alleviate the issue.
Using the MLE is not without problems. As we saw in Figure 2.1, convergence can be slow, since we are not using any side information. The latter
can provide us with problems which are both numerically better conditioned
and which show better convergence, provided that our assumptions are accurate. Before discussing a Bayesian approach to estimation, let us discuss
basic statistical properties of the estimator.
2.4 Estimation
69
Fig. 2.11. Left: unbiased estimator; the estimates, denoted by circles have as mean
the true parameter, as denoted by a star. Middle: consistent estimator. While the
true model is not within the class we consider (as denoted by the ellipsoid), the
estimates converge to the white star which is the best model within the class that
approximates the true model, denoted by the solid star. Right: different estimators
have different regions of uncertainty, as made explicit by the ellipses around the
true parameter (solid star).
70
2 Density Estimation
m 2 [[X]
] N(0, 2 g()
).
(2.59)
[X]
when performing estimation. The Cramer-Rao bound governs this.
Theorem 2.19 (Cram
er and Rao [Rao73]) Assume that X is drawn from
(2.60)
(2.61)
Note that at the true parameter the expected log-likelihood score vanishes
EX [ log p(X; )] =
p(X; )dX = 1 = 0.
(2.62)
Hence we may simplify the covariance formula by dropping the means via
p(X; )(X)
log p(X; )d
p(X; )(X)dX
= = 1.
2.4 Estimation
71
(2.63)
(X).
Theorem 2.18 implies that for exponential families MLE is asymptotically efficient. It turns out to be generally true.
Theorem 2.20 (Efficiency of MLE [Cra46, GW92, Ber85]) The maximum likelihood estimator is asymptotically efficient (e = 1).
generating p(; X). If this is not true, we need to settle for less: how well [X]
approaches the best possible choice of within the given model class. Such
behavior is referred to as consistency. Note that it is not possible to define
consistency per se. For instance, we may ask whether converges to the
converges to the optimal density
optimal parameter , or whether p(x; )
p(x; ), and with respect to which norm. Under fairly general conditions
this turns out to be true for finite-dimensional parameters and smoothly
parametrized densities. See [DGL96, vdG00] for proofs and further details.
72
2 Density Estimation
turns out to be the tool to building estimators which work well in high
dimensions.
Recall Bayes rule (1.15) which states that p(|x) = p(x|)p()
. In our conp(x
text this means that if we are interested in the posterior probability of
assuming a particular value, we may obtain this using the likelihood (often
referred to as evidence) of x having been generated by via p(x|) and our
prior belief p() that might be chosen in the distribution generating x.
Observe the subtle but important difference to MLE: instead of treating
as a parameter of a density model, we treat as an unobserved random
variable which we may attempt to infer given the observations X.
This can be done for a number of different purposes: we might want to
infer the most likely value of the parameter given the posterior distribution
p(|X). This is achieved by
MAP (X) := argmax p(|X) = argmin log p(X|) log p().
(2.64)
The second equality follows since p(X) does not depend on . This estimator
is also referred to as the Maximum a Posteriori, or MAP estimator. It differs
from the maximum likelihood estimator by adding the negative log-prior
to the optimization problem. For this reason it is sometimes also referred
to as Penalized MLE. Effectively we are penalizing unlikely choices via
log p().
Note that using MAP (X) as the parameter of choice is not quite accurate.
After all, we can only infer a distribution over and in general there is no
guarantee that the posterior is indeed concentrated around its mode. A more
accurate treatment is to use the distribution p(|X) directly via
p(x|X) =
p(x|)p(|X)d.
(2.65)
In other words, we integrate out the unknown parameter and obtain the
density estimate directly. As we will see, it is generally impossible to solve
(2.65) exactly, an important exception being conjugate priors. In the other
cases one may resort to sampling from the posterior distribution to approximate the integral.
While it is possible to design a wide variety of prior distributions, this book
focuses on two important families: norm-constrained prior and conjugate
priors. We will encounter them throughout, the former sometimes in the
guise of regularization and Gaussian Processes, the latter in the context of
exchangeable models such as the Dirichlet Process.
2.4 Estimation
73
(2.66)
That is, they restrict the deviation of the parameter value from some guess
0 . The intuition is that extreme values of are much less likely than more
moderate choices of which will lead to more smooth and even distributions
p(x|).
A popular choice is the Gaussian prior which we obtain for p = d = 1
and = 1/2 2 . Typically one sets 0 = 0 in this case. Note that in (2.66)
we did not spell out the normalization of p() in the context of MAP
estimation this is not needed since it simply becomes a constant offset in
the optimization problem (2.64). We have
MAP [X] = argmin m [g() , [X] ] + 0
d
p
(2.67)
Fig. 2.12. From left to right: regions of equal prior probability in R2 for priors using
the 1 , 2 and norm. Note that only the 2 norm is invariant with regard to the
coordinate system. As we shall see later, the 1 norm prior leads to solutions where
only a small number of coordinates is nonzero.
74
2 Density Estimation
(2.68)
exp ( n, ng()) d.
(2.69)
Note that p(|n, ) itself is a member of the exponential family with the
feature map () = (, g()). Hence h(, n) is convex in (n, n). Moreover,
the posterior distribution has the form
p(|X) p(X|)p(|n, ) exp ( m[X] + n, (m + n)g()) . (2.70)
That is, the posterior distribution has the same form as a conjugate prior
and m + n. In other words, n acts like a phantom
with parameters m[X]+n
m+n
sample size and is the corresponding mean parameter. Such an interpretation is reasonable given our desire to design a prior which, when combined
with the likelihood remains in the same model class: we treat prior knowledge as having observed virtual data beforehand which is then added to the
actual set of observations. In this sense data and prior become completely
equivalent we obtain our knowledge either from actual observations or
from virtual observations which describe our belief into how the data generation process is supposed to behave.
Eq. (2.70) has the added benefit of allowing us to provide an exact normalized version of the posterior. Using (2.68) we obtain that
p(|X) = exp
m[X] + n, (m + n)g() h
m[X]+n
,m
m+n
+n
m[X] + n, (m + n)g() h
m[X]+n
,m
m+n
+n
Combining terms one may check that the integrand amounts to the normalization in the conjugate distribution, albeit (x) added. This yields
p(x|X) = exp h
m[X]+n+(x)
,m
m+n+1
+n+1 h
m[X]+n
,m
m+n
+n
2.4 Estimation
75
can be integrated out to obtain what is called a collapsed Gibbs sampler for
topic models [BNJ03].
2.4.4 An Example
Assume we would like to build a language model based on available documents. For instance, a linguist might be interested in estimating the frequency of words in Shakespeares collected works, or one might want to
compare the change with respect to a collection of webpages. While models describing documents by treating them as bags of words which all have
been obtained independently of each other are exceedingly simple, they are
valuable for quick-and-dirty content filtering and categorization, e.g. a spam
filter on a mail server or a content filter for webpages.
Hence we model a document d as a multinomial distribution: denote by
wi for i {1, . . . , md } the words in d. Moreover, denote by p(w|) the
probability of occurrence of word w, then under the assumption that the
words are independently drawn, we have
md
p(wi |).
p(d|) =
(2.71)
i=1
It is our goal to find parameters such that p(d|) is accurate. For a given
collection D of documents denote by mw the number of counts for word w
in the entire collection. Moreover, denote by m the total number of words
in the entire collection. In this case we have
p(w|)mw .
p(di |) =
p(D|) =
i
(2.72)
mw
.
m
(2.73)
76
2 Density Estimation
mw + nw
m w + nw
=
.
m+n
m+n
(2.74)
In other words, we add the pseudo counts nw to the actual word counts mw .
This is particularly useful when the document we are dealing with is brief,
that is, whenever we have little data: it is quite unreasonable to infer from
a webpage of approximately 1000 words that words not occurring in this
page have zero probability. This is exactly what is mitigated by means of
the conjugate prior (, n).
Finally, let us consder norm-constrained priors of the form (2.66). In this
case, the integral required for
p(D) =
p(D|)p()d
exp 0
d
p
+ m [D], mg() d
0
m
d
p.
(2.75)
A very simple strategy for minimizing (2.75) is gradient descent. That is for
a given value of we compute the gradient of the objective function and take
a fixed step towards its minimum. For simplicity assume that d = p = 2 and
= 1/2 2 , that is, we assume that is normally distributed with variance
2 and mean 0 . The gradient is given by
[ log p(D, )] = Exp(x|) [(x)] [D] +
1
[ 0 ]
m 2
(2.76)
2.5 Sampling
77
Taylor approximation
1
log p(D, + ) log p(D, ) + , G + H
(2.77)
2
where G and H are the first and second derivatives of log p(D, ) with
respect to . The quadratic expression can be minimized with respect to
by choosing = H 1 G and we can fashion an update algorithm from this
by letting H 1 G. One may show (see Chapter 5) that Algorithm 2.1
is quadratically convergent. Note that the prior on ensures that H is well
conditioned even in the case where the variance of (x) is not. In practice this
means that the prior ensures fast convergence of the optimization algorithm.
Algorithm 2.1 Newton method for MAP estimation
NewtonMAP(D)
Initialize = 0
while not converged do
1
Compute G = Exp(x|) [(x)] [D] + m
2 [ 0 ]
1
Compute H = Varxp(x|) [(x)] + m2 1
Update H 1 G
end while
return
2.5 Sampling
So far we considered the problem of estimating the underlying probability
density, given a set of samples drawn from that density. Now let us turn to
the converse problem, that is, how to generate random variables given the
underlying probability density. In other words, we want to design a random
variable generator. This is useful for a number of reasons:
We may encounter probability distributions where optimization over suitable model parameters is essentially impossible and where it is equally impossible to obtain a closed form expression of the distribution. In these cases
it may still be possible to perform sampling to draw examples of the king
of data we expect to see from the model. Chapter 3 discusses a number of
graphical models where this problem arises.
Secondly, assume that we are interested in testing the performance of a
network router under different load conditions. Instead of introducing the
under-development router in a live network and wreaking havoc, one could
estimate the probability density of the network traffic under various load
conditions and build a model. The behavior of the network can then be
78
2 Density Estimation
2.5 Sampling
79
Fig. 2.13. Left: discrete probability distribution over 5 possible outcomes. Right:
associated cumulative distribution function. When sampling, we draw x uniformly
at random from U [0, 1] and compute the inverse of F .
This follows immediately by applying a variable transformation for a measure, i.e. we change dp(x) to dp(1 (z)) z 1 (z) . Such a conversion strategy is particularly useful for univariate distributions.
Corollary 2.22 Denote by p(x) a distribution on R with cumulative distrix
bution function F (x ) = dp(x). Then the transformation (x) = F 1 (x)
converts samples from U [0, 1] to samples drawn from p(x).
We now apply this strategy to a number of univariate distributions. One of
the most common cases is sampling from a discrete distribution.
Example 2.8 (Discrete Distribution) In the case of a discrete distribution over {1, . . . , k} the cumulative distribution function is a step-function
with steps at {1, . . . , k} where the height of each step is given by the corresponding probability of the event.
The implementation works as follows: denote by p [0, 1]k the vector of
probabilities and denote by f [0, 1]k with fi = fi1 + pi and f1 = p1 the
steps of the cumulative distribution function. Then for a random variable z
drawn from U [0, 1] we obtain x(z) := argmaxi {fi z}. See Figure 2.13 for
an example of a distribution over 5 events.
Example 2.9 (Laplace Distribution) The density of a Laplace-distributed
random variable is given by
p(x|) = exp(x) if > 0 and x 0.
(2.78)
80
2 Density Estimation
Fig. 2.14. Left: Laplace distribution with = 1. Right: associated cumulative distribution function. When sampling, we draw x uniformly at random from U [0, 1]
and compute the inverse.
(2.79)
(2.80)
The key observation is that the joint distribution p(x, y) is radially symmetric, i.e. it only depends on the radius r2 = x2 + y 2 . Hence we may perform
a variable substitution in polar coordinates via the map where
x = r cos and y = r sin hence (x, y) = (r, ).
(2.81)
2.5 Sampling
81
0.45
0.40
0.35
0.30
0.25
0.20
0.15
0.10
0.05
0.00 4
Fig. 2.15. Red: true density of the standard normal distribution (red line) is contrasted with the histogram of 20,000 random variables generated by the Box-M
uller
transform.
1 1 r2
e 2
2
cos
sin
r sin r cos
r 1 r2
e 2 .
2
The fact that p(r, ) is constant in means that we can easily sample
[0, 2] by drawing a random variable, say z from U [0, 1] and rescaling it with
2. To obtain a sampler for r we need to compute the cumulative distribution
1 2
function for p(r) = re 2 r . The latter is given by applying (2.81):
r
F (r ) =
1 2
re 2 r dr = e 2 z
and hence r =
2 log F (r).
(2.82)
This yields the following sampler: draw z , zr U [0, 1] and compute x and
y by
x=
2 log zr sin 2z .
if x2 + y 2 1
otherwise
(2.83)
82
2 Density Estimation
Fig. 2.16. Rejection sampler. Left: samples drawn from the uniform distribution on
[0, 1]2 . Middle: the samples drawn from the uniform distribution on the unit disc
are all the points in the grey shaded area. Right: the same procedure allows us to
sample uniformly from arbitrary sets.
if r 1
otherwise
(2.84)
Solving the integral for yields p(r) = 2r for r [0, 1] with corresponding
CDF F (r) = r2 for r [0, 1]. Hence our sampler draws zr , z U [0, 1] and
2.5 Sampling
83
3.0
2.5
2.5
2.0
2.0
1.5
1.5
1.0
1.0
0.5
0.0
0.5
0.0
0.2
0.4
0.6
0.8
1.0
0.00.0
0.2
0.4
0.6
0.8
1.0
Fig. 2.17. Accept reject sampling for the Beta(2, 5) distribution. Left: Samples are
generated uniformly from the blue rectangle (shaded area). Only those samples
which fall under the red curve of the Beta(2, 5) distribution (darkly shaded area)
are accepted. Right: The true density of the Beta(2, 5) distribution (red line) is
contrasted with the histogram of 10,000 samples drawn by the rejection sampler.
p(x)
cq(x)
q(x)
c1
Pr(Z|x)q(x)dx =
= p(x)
(2.85)
c1 p(x)dx = c1 .
Note that the algorithm of Example 2.12 is a special case of such a rejection
1
sampler we majorize pX by the uniform distribution rescaled by p(X)
.
Example 2.14 (Beta distribution) Recall that the Beta(a, b) distribution,
84
2 Density Estimation
(a + b) a1
x (1 x)b1 ,
(a)(b)
(2.86)
a1
.
a+b2
(2.87)
|x|
e
2
(2.88)
2e
q(x| = 1)
p(x| 2 ) = (2) 2 d e 22
Now suppose that we want to draw from p(x| 2 ) by sampling from another
Gaussian q with slightly larger variance 2 > 2 . In this case the ratio
2.5 Sampling
85
0.7
p(x)
2e
0.6
g(x|0,1)
0.5
0.4
0.3
0.2
0.1
0.0 4
Fig. 2.18. Rejection sampling for the Normal distribution (red curve). Samples are
generated uniformly from the Laplace distribution rescaled by 2e/. Only those
samples which fall under the red curve of the standard normal distribution (darkly
shaded area) are accepted.
q(0| 2 )
=
p(0|2 )
Problems
Problem 2.1 (Bias Variance Decomposition {1}) Prove that the variance VarX [x] of a random variable can be written as EX [x2 ] EX [x]2 .
Problem 2.2 (Moment Generating Function {2}) Prove that the characteristic function can be used to generate moments as given in (2.12). Hint:
use the Taylor expansion of the exponential and apply the differential operator before the expectation.
86
2 Density Estimation
erf(x) =
2/
ex dx.
(2.89)
Problem 2.4 (Weak Law of Large Numbers {2}) In analogy to the proof
of the central limit theorem prove the weak law of large numbers. Hint: use
a first order Taylor expansion of eit = 1 + it + o(t) to compute an approximation of the characteristic function. Next compute the limit m for
X m . Finally, apply the inverse Fourier transform to associate the constant
distribution at the mean with it.
Problem 2.5 (Rates and confidence bounds {3}) Show that the rate
of hoeffding is tight get bound from central limit theorem and compare to
the hoeffding rate.
Problem 2.6 Why cant we just use each chip on the wafer as a random
variable? Give a counterexample. Give bounds if we actually were allowed to
do this.
Problem 2.7 (Union Bound) Work on many bounds at the same time.
We only have logarithmic penalty.
Problem 2.8 (Randomized Rounding {4}) Solve the linear system of
equations Ax = b for integral x.
Problem 2.9 (Randomized Projections {3}) Prove that the randomized projections converge.
Problem 2.10 (The Count-Min Sketch {5}) Prove the projection trick
Problem 2.11 (Parzen windows with triangle kernels {1}) Suppose
you are given the following data: X = {2, 3, 3, 5, 5}. Plot the estimated density using a kernel density estimator with the following kernel:
k(u) =
Problem 2.12 Gaussian process link with Gaussian prior on natural parameters
Problem 2.13 Optimization for Gaussian regularization
2.5 Sampling
87
=
m
1
xi and
=
m
i=1
(xi
)2
(2.90)
i=1
using the exponential families parametrization. Next show that while the
1
mean estimate
is unbiased, the variance estimate has a slight bias of O( m
).
2
To see this, take the expectation with respect to
.
Problem 2.20 (cdf of Logistic random variable {1}) Show that the cdf
of the Logistic random variable (??) is given by (??).
Problem 2.21 (Double-exponential (Laplace) distribution {1}) Use
the inverse-transform method to generate a sample from the double-exponential
(Laplace) distribution (2.88).
Problem 2.22 (Normal random variables in polar coordinates {1})
If X1 and X2 are standard normal random variables and let (R, ) denote the polar coordinates of the pair (X1 , X2 ). Show that R2 22 and
Unif[0, 2].
Problem 2.23 (Monotonically increasing mappings {1}) A mapping
T : R R is one-to-one if, and only if, T is monotonically increasing, that
is, x > y implies that T (x) > T (y).
88
2 Density Estimation
a0 + a1 t
,
1 + b1 t + b2 t2
(2.91)
3
Directed Graphical Models
90
3.1 Introduction
3.1.1 Alarms and Burglars
Directed graphical models are some of the most intuitive ways of describing
dependencies between random variables. Consider the following chain of
events which will serve as a running example in this section: we denote by
B the event that your house is burgled, let A be the event that the alarm
in the house is triggered, and let N be the event that you receive a phone
call from your neighbor. To model this set of events we can always write
p(B, A, N ) = p(B)p(A, N |B) = p(B)p(A|B)p(N |B, A).
(3.1)
In other words, we may start with the probability of a burglary, the probability of the alarm being triggered by the burglary, and finally, the probability
of the neighbor calling given the burglary and the alarm. It is here that we
can make a simplifying modeling assumption: the probability of the neighbor does not directly depend on the burglar but only on the alarm being
triggered. This is probably reasonable since burglars tend to be stealthy and
try not being seen by neighbors. In other words, we assume that
p(N |B, A) = p(N |A) and hence p(B, A, N ) = p(B)p(A|B)p(N |A).
(3.2)
p(B, A, N )
=
B ,N p(B , A, N )
p(B )p(A|B )
p(N |A)
B p(B )p(A|B )
(3.3)
=p(B|A)p(N |A).
We express the fact that B and A are conditionally independent given A
as B
N |A. Note that above we dropped the summation over N above
3.1 Introduction
91
Fig. 3.1. From left to right: a simple three variable model involving a burglary
B, an alarm A, and a phone call from a neighbor N . The second model from the
left denotes that we observe A. This is typically indicated by solid colored nodes.
The second graph from the right denotes a model where we added another random
variable, the event of an earthquake. Note that while B and E are independent of
each other, they cease being so once we observe A or N . Clearly, we can add further
random variables, e.g. whether we receive information about an earthquake on the
radio R.
since by definition N p(N |A) = 1. This means that for a given model,
inference is simpler, since we may split the chain of reasoning into one part
affecting the random variables (B, A) and a second part affecting (A, N ).
Graphically we may describe the model by the directed graph of Figure 3.1. The key issue was that we were able to drop the arc B N from
the diagram. Here the arrow B N has the semantic that N depends on
B. Such diagrams are quite useful in specifying chains of causality.
Let us now extend the model somewhat. Californian homes are threatened
by earthquakes. Hence let us add the random variable E denoting such
an event. Obviously earthquakes may trigger the alarm A. On the other
hand, we can assume that burglars B are not privy to advance knowledge
of earthquakes, hence the events B and E can reasonably be considered to
be independent (we ignore looting). It is an equally reasonable assumption
that alarms and phone calls will not trigger earthquakes. This leads to the
model (see Figure 3.1)
p(B, A, N, E) = p(B)p(E)p(A|B, E)p(N |A).
(3.4)
While obviously B and E are independent, let us now consider the situation
that we observe A. In this case, the probability p(B, E|A) does not factorize
in B and E any more. In other words, conditioned on the alarm A, the
92
This effect is often referred to as explaining away since now the observation
of a joint effect couples the causes. It is easy to check (see Problem 4.2) that
the same holds when conditioning on N rather than A. What happens is
that the information that it is likely either a burglar or an earthquake but
quite unlikely both at the same time gets passed along to N .
Fig. 3.2. From left to right: an undirected planar graph, that is a graph that can
be represented on a plane without crossing edges. Middle: a directed acyclic graph
it does not contain cycles. Right: a directed loop.
3.1 Introduction
93
p(X) =
(3.5)
iV
94
Fig. 3.3. A Markov chain. Each random variable i depends on its predecessor i 1.
Clearly, observing 5 makes {1, 2, 3, 4} independent from {6, 7}.
(a)
(b)
(c)
(d)
(e)
(f)
Fig. 3.4. Transition behavior of the Bayes-ball algorithm. The ball may only pass
whenever variables depend on each other: (a) The variables A and C depend on each
other via B; (b) A and C are independent, since B is not observed and it therefore
can be integrated out without side effects; (c) A and C depend on each other through
the joint conditioning on their parent B; (d) Observing B makes C independent of
A; The ball bounces back for C to deal with downstream dependencies. This is a
special case of the next diagram; (e) Since B has A and C as causes, observing B
makes A and C dependent (e.g. imagine an XOR relationship); (f) observing the
joint cause of A and C makes them independent. The Bayes-ball algorithm simply
allows messages to travel along lines of dependence, as indicated by the arrows on
the side of B.
3.1 Introduction
95
from the sets, and a second one which allows us to check dependence between
random variables by a reachability problem on a graph.
Theorem 3.3 ([Pea01]) Denote by A, B, C three sets of random variables
associated with a DAG G(V, E). In this case A
B|C if and only if a
b|C
holds for all a A and b B.
Theorem 3.4 ([GVP90]) Denote a, b random variables and C a set of
random variables associated with a DAG G(V, E). Then a and b are dependent given C if there exists a path from a to b where each node with two
incoming arcs on the path either is or has a descendant in C. If no such
paths exists we call a, b to be d-separated by C.
Figure 3.4 explains the rationale behind this theorem: two variables i, j
depend on each other when the connecting variable k is unobserved and it is
not a joint child of i and j. This relation is reversed when we observe j. In
this case, only if j is a joint child of i and j, the observation of k renders i and
j dependent. Theorem 3.4 states that this dependence is transitive, that is,
it is inherited along a chain of random variables. Algorithm 3.1 determines
the reachability efficiently. Moreover, its runtime is linear in the size of the
graph G(V, E).
Theorem 3.5 ([Sha98]) For a given graph G(V, E) algorithm 3.1 terminates in at most O(|V | + |E|) time. Moreover for disjoint sets A, C V the
set B = BayesBall(G(V,E), A, C) contains all variables which are conditionally dependent on A given C.
Proof Each vertex is visited at most twice since we set the flags ti and
bi according to whether we follow to the children or parents of a vertex.
Moreover, we follow each edge at most twice (once from the parent and once
from the descendant).
To see the dependence, note that algorithm 3.1 is a reachability test:
the variables ti and bi are only book-keeping tools to ensure that we do
not traverse a given edge in a given direction twice (ti deals with childparent paths, bj with parent-child paths). Now note that any path between
vertices a A and b B will traverse an unobserved vertex i C with the
exception of a parent-child-parent path or unless the ball bounces back from
an observed descendant. Moreover, it will traverse an observed vertex i C
only if it is a parent-child-parent path. This is consistent with Theorem 3.4,
which concludes our proof.
The notion of directed graphical models can be extended to deterministic
96
3.2 Estimation
So far we demonstrated that directed graphical models are a versatile tool
when it comes to specifying dependencies in human-readable form. If we
observe all variables in the graph we are immediately able to read off the
probability / density for the corresponding event. Many applications, however, do not fit into this category typically we observe only some of the
variables while the others are unknown. In this context we would like to
perform three basic operations: we would like to quantify the density of
the observed variables. This requires an operation called Marginalization.
A second question is to determine the density of some configuration of the
unobserved variables conditioned on the observed random variables. This
requires Conditioning. Finally, we may want to adjust the parameters of
3.2 Estimation
97
the model itself. While this, strictly speaking, could be viewed as a case of
marginalization over the unknown model parameters, it is practically useful,
nonetheless, to study algorithms such as Expectation Maximization, which
can be tailored towards the adaptation of model parameters.
Let us the discuss the basic operations in some more detail. The example
of Figure 3.1 will serve as an example to motivate the problem further.
Marginalization: Assume that we are only interested in the probability
of receiving a phone call from our neighbor N . In this case we
need to sum over all possible constellations of (B, A, N ) to obtain
p(N ) = B,A,N p(B, A, N, E). In other words, we integrate out the
unobserved random variables in order to obtain the marginal distribution of the random variable we are actually interested in.
More formally, given a distribution p(X, Y ) we want to compute
p(X). This requires us to sum over the variables Y via
p(X) =
p(Zi |ZPar(i) )
p(X, Y ) =
y
(3.6)
iV
p(X, Y )
.
p(X)
(3.7)
98
p(xij |Par(xij ); ) =
log p(x)dp(x)
(3.8)
xX
3.2 Estimation
99
{1, . . . , n} is drawn iid from p with entropy H(p). Then in the limit of
m the average number of bits required to encode any element of X
is given by H(p)
log 2 .
In other words, it is possible to encode the datastream drawn from p with
H(p)
log 2 bits per symbol. Moreover, it is impossible to decode it with less than
that threshold if lossless compression is required.
A simple example of the above theorem can be seen as follows: if we have a
distribution over 2n equidistributed events we could obviously encode each
of the events with n bits. However, if one of these events were to occur
very frequently, we might want to reserve a shorter bit sequence for the
frequent event at the expense of investing more bits for the less frequent
terms. Theorem 3.6 indicates that the best possible code to encode event
x should require log2 p(x) bits. For continuous variables this analogy is,
unfortunately, somewhat fragile, since by their very nature, storing numbers
in R at full precision almost always requires an infinite number of bits.
Nonetheless, entropy proves to be a useful concept when measuring the
complexity of distributions under consideration.
Kullback Leibler Divergence Given two distributions it is only natural
to define a distance between them. We will discuss this topic in great detail in
Section 10 where we will be analyzing it from the viewpoint of expectations
over a given set of random variables. In the context of information theory
we may compute distances between distributions by asking how many extra
bits we would need to spend on encoding data drawn from p when using
the code for q rather than the (optimal) code for p. This is precisely the
Kullback Leibler (KL) Divergence:
D(p q) :=
log
p(x)
dp(x) and D(p q) :=
q(x)
log
xX
p(x)
p(x)
q(x)
(3.9)
100
q(x)
q(x)
log Ex
= log 1 = 0.
p(x)
p(x)
(3.10)
One may check that I(X, Y ) = D(pX,Y pX pY ), that is, the mutual information is the distance between the joint distribution in X and Y and
the product of its marginals. Consequently we have that I(X, Y ) 0 and
moreover that I(X, Y ) = 0 if an only if pX,Y = pX pY . Finally we have
H(pX,Y ) =
3.2 Estimation
101
y1
y2
y3
x1
xi
xi
...
ym
yi
yi
xm
xi
xi
i=1..m
1,
1
...
k,
k
j,j
i=1..m
j,j
j=1..k
j=1..k
Fig. 3.5. K-means clustering as a graphical model. We assume that there exists some
distribution over k terms, denoted by yi which generates vector-valued observations
xi . The diagram in the middle represents the same model, now in plate notation.
The model on the right hand side is an extension obtained by adding conjugate
priors on , and .
concretely. Its simplicity allows us to focus on concepts rather than problemspecific details. A considerable number of additional more complex examples covering applications ranging from Hidden Markov Models to Latent
Dirichlet Allocation and Collaborative Filtering models can be found in Section 3.3.
Consider the setting in Figure 3.5 which describes the basic mixture of
Gaussians clustering model. In the graph on the left hand side xi Rn
denote observations, yi {1, . . . k} correspond to the latent cluster membership variables, denotes the discrete distribution over class memberships
and j , j denote the means and variances of x for a given cluster membership. We may express this model as follows:
m
p(X, Y|, , ) =
i=1
m
(3.11)
1
yi (xi yi )
p(yi |) (3.12)
i=1
102
maximize
,,
i=1
(2) 2 |y | 2 e 2 (xi y )
log
1
y (xi y )
p(y|)
(3.13)
yY
(3.14)
This can be seen directly from (3.12): all y are multiples of the identity matrix and p(y|) is constant, hence the only term that matters is the distance
from the cluster mean. Once we have determined the most likely cluster
assignments we can compute the most likely cluster centers by solving
m
= argmax
i=1
x i y
yi =y
1
xi .
|{yi = y}| y =y
i
3.2 Estimation
103
The second equality follows from the fact that only terms for which yi = y
depend on y and that p(y|) is constant. The above pair of equations yields
the k-means clustering algorithm (Algorithm 3.2).
Theorem 3.9 (k-means Convergence) Algorithm 3.2 converges in a finite number of iterations.
Proof At each step the likelihood of the data wrt. Y and is increased,
hence the algorithm either makes progress or it has converged. Since the set
of assignments Y {1, . . . , k}m is finite the number of steps is finite, too.
Note that while this shows convergence in a finite number of steps it does
not provide any guarantee regarding the rate of convergence. In practice,
though, k-means converges very quickly (often 10s of steps).
(3.15)
104
end while
return
This shows the inequality. To see that the bound is tight, simply note that
for q(y) = p(y|x; ) the KL-divergence vanishes.
This inequality immediately suggests a procedure to maximize p(x; ): for
a given choice of q maximize Eyq(y) [log p(x, y; )]. Subsequently adapt q
and repeat. Note that this increases the lower bound on the best possible
value of log p(x; ) at every step: this is clearly the case when optimizing
over . Moreover, when recomputing q we tighten the lower bound (it becomes exact in this case), hence the lower bound increases again. This is
what is described in Algorithm 3.3. This procedure is known as the Expectation Maximization (EM) algorithm. One may show [DLR77] that the EM
algorithm is convergent. Note though, that in general it is difficult to obtain
guarantees on the rate of convergence.
Theorem 3.11 (EM Convergence) Algorithm 3.3 generates monotonically increasing likelihood scores for p(x|) and it converges to a local maximum of the likelihood.
In the context of maximum likelihood estimation for clustering the latent
variables are the cluster memberships yi whereas the parameters are given
by , i , i . For a given choice of the latter the probability p(y|x; , , )
factorizes into p(yi |xi ; , , ) which leads to
n
1
y (xi y )
(3.16)
3.2 Estimation
105
L(q, , , ) =
i=1 y
m
1
2
mn
log 2+
2
(3.17)
qi (y)
(3.18)
i=1
Next note that the problem of minimizing L decomposes into separate subproblems for each value of y. Taking with respect to y and y yields
m
qi (y)1
y (xi y )
y L =
(3.19)
i=1
1
qi (y) 1
y y
y L =
i
qi (y)(xi y )(xi y )
1
(3.20)
y
Solving the above with respect to and yields the well-known k-means
clustering equations: for my = m
i=1 qi (y) update
1
y =
my
m
i=1
1
qi (y)xi and y =
my
qi (y)(xi y )(xi y ) .
(3.21)
i=1
106
m
i=1 qi (y)xi xi
y y
(3.22)
3.2 Estimation
107
(3.23)
(3.24)
In the context of clustering we have two sets of variables: the cluster labels
Y which can be sampled efficiently given , , , and the model parameters
(i , i ) and , all of which again can be sampled independently of each other
for given Y . As we can see, the main difference between k-means, the Mixture
of Gaussians clustering, and the Gibbs sampling algorithm is that rather
than finding optimal assignments we now sample from the distribution. The
fact that we alternate between cluster description and model description
remains unchanged. In the following we describe these steps in more detail.
Drawing from Pr(yi |xi , , , )
Drawing from Pr(|Y )
1
Note that in this case there is no need whatsoever to distinguish between latent variables and
parameters at all. Overall, we have a joint distribution over the unobserved variables and the
parameters of the model.
108
3.3 Applications
109
x1
x2
x3
x4
y1
y2
y3
y4
...
xm
xi
ym
yi
xi+1
i=1..m
Fig. 3.6. A simple hidden Markov model. The variables xi are observed, while the
states yi responsible for generating xi are unknown. The graph on the right is an
equivalent representation as a plate. Our notation is slightly sloppy by not dealing
explicitly with the last hidden state y10 which does not have a child y11 . That said,
since y11 is an unobserved child node in the DAG, it integrates out without any
further effect on the joint probability distribution.
m1
p(x, y) = p(y1 )
(3.25)
i=1
110
p(y1 )
p(x) =
y1 ,...,ym
(3.26)
i=1
m1
=
y2 ,...,ym
y1
i=2
:=f2 (y2 )
m1
=
y3 ,...,ym
y2
i=3
:=f3 (y3 )
While the original sum is most likely to be too costly as it involves a sum over
an exponential number of terms, we have managed to compute it step-bystep simply by pushing summations into the product of factors. Extending
this idea we can compute p(x) by solving the recursion
f1 (y1 ) = p(y1 )p(x1 |y1 ), fi (yi ) = p(xi |yi )
(3.28)
yi+1
such that p(x) = y1 p(y1 )b1 (y1 ). The recursions (3.27) and (3.28) are commonly known as the forward and backward passes through a Hidden Markov
model. Note that both of them can be computed in linear time in the length
of the chain.
Now assume that we want to obtain the probability p(yi |x) By Bayes rule
i)
these probabilities can be computed via p(yi |x) = p(x,y
p(x) The only difference
is that we must not perform the summation over yi to obtain the correct
numerator. This is achieved as follows: we perform the forward pass of (3.27)
until we reach fi (yi ). Likewise we perform the backward pass until we reach
bi (yi ). This yields that
p(x, yi ) =
(3.29)
An analogous reasoning leads to p(x, yi , yi+1 ) = fi (yi )p(yi+1 |yi )bi+1 (yi+1 ).
3.3 Applications
111
(3.30)
i=1
Note that it is precisely the expectations with respect to yi and with respect
to (yi , yi+1 ) that we need to compute the expected log-likelihood. Assuming
that we are dealing with a HMM clustering model with Gaussian outputs,
that is yi {1, . . . , k} and xi |yi N(yi , y2i ), we obtain update equations
very similar to clustering. In fact, only (??) needs changing. Eq. (??) and
(??) remain unchanged. The difference is that now instead of estimating
p(yi |) we have the equations
p(y1 ; ) = q(y1 ) and p(yi+1
1
= a|yi = b; ) =
m1
q(yj+1 = a|yj = b)
j=1
In other words, we pick the transition probabilities p(yi+1 |yi ) as the average over the posterior transition probabilities p(yi+1 |yi , x). Only the initial
probability p(y1 ) is treated differently. The probabilities p(xi |yi ), also called
emission probabilities, are identical to what is done in a clustering model.
While the above model is deceptively simple we have a transition
between a given number of states which emit Gaussian random variables,
they form the basis of advanced speech [BM90] and handwriting recognition
[LBBH98] algorithms and they have found widespread applications to bioinformatics [DEKM98]. There exist countless variants on the HMM theme. See
e.g. Figure 3.7 for some examples.
112
y1
...
x2
x3
xi+1
yi
yi+1
zi
i=1..m
yn
yi
x1
xi
...
xm
zi
yi+1
i=1..m
Fig. 3.7. Left: Factor analysis. The observations x1 , . . . , xm arise from latent factors y1 , . . . , yn which are considered independent. Middle: an Input-Output HMM.
A sequence x1 , . . . , xm is observed and transcribed according to a hidden state
y1 , . . . , ym into an output z1 , . . . , zm . For instance, translation models can be fashioned after this structure. Right: a factorial HMM. To deal with richly structured
states we assume that instead of having just a single latent set of states y1 , . . . , ym
which cause z1 , . . . , zm , we have an additional set x1 , . . . , xm . For instance, x could
represent the text we are trying to read and y could correspond to the vocal apparatus which is generating speech.
(3.31a)
(3.31b)
(3.31c)
In other words, we assume that the hidden state evolves according to a dynamical system yi+1 = y + Ayi with some Gaussian noise with variance y
added, and where the observations are affine transformations of the hidden
state xi = x + Byi with some Gaussian noise x added.
Since the sum of two Gaussians is Gaussian again (see Problem 4.12), it
follows that if yi was Gaussian then also both yi+1 and xi are. By and large,
the estimation of the distributions p(yi+1 |yi ) and p(xi |yi ) proceeds in the
same fashion as in the case of the discrete Hidden Markov Model. See e.g.
[Hay91, WB06] for details. For illustration purposes we discuss how xi and
yi+1 are related, conditioned on yi .
Assume that yi N(i , i ). By (3.31b) and (3.31c) it follows that the
random variables (xi , yi+1 ) are jointly Gaussian: they have a variable offset
(Byi , Ayi ) which is Gaussian. Moreover, we can compute the means and
variances easily by exploiting that they are both additive. Hence we have
3.3 Applications
113
that
yi+1
xi
y + A
x + B
y + AA
BA
AB
x + BB
(3.32)
If we observe xi we can use this to improve our estimate of yi+1 . Using (4.5)
of Problem 4.15 we may check that yi+1 |xi N(i+1 , i+1 ) where
i+1 = y + Ai + Ai B (x + Bi B )1 (xi x Bi )
i+1 = y + Ai A Ai B (x + Bi B )
Bi A
(3.33)
(3.34)
The above equations can be used to track the variables yi via the indirect
observations xi . Note that the same could be achieved in the discrete case.
For details on inference and nonlinear extensions see [WB06].
114
zij
wij
i=1..m
l
j=1..mi
l=1..k
Fig. 3.8. Latent Dirichlet Allocation. For given parameters , we draw multinomial distributions i and l from Dirichlet distributions with and respectively.
Subsequently we draw mi topics zij for each document. Finally, for every topic zij
we draw a word wij from the corresponding topic distribution zij .
Problems
Problem 3.1 (Chain Smoker) Smoking - tar in the lungs - cancer. Asbestos. What happens now? What if we know that the guy was in the construction industry and had to deal with asbestos?
Problem 3.2 (Burglar, Earthquake, and Neighbor) Show that in our
3.3 Applications
115
vi
ci
ui
vi+1
10
116
Problem 3.13 Modify the HMM of Figure 3.6 to account for a conjugate
prior on the transition probabilities and the emission probabilities. Hint: use
a Dirichlet prior for p(yi+1 |yi ) and a Wishart prior for p(xi |yi ). Design an
EM algorithm for it. This is a generalization of Problem 4.7.
Problem 3.14 (Gaussian Models) Show that the sum of n independent
Gaussians is Gaussian again and that means and show that means and variances are additive. Moreover, show that that if (x, y) is jointly Gaussian,
then also the marginal x and the conditional x|y are. Compute their means
and variances.
Problem 3.15 (Sparse Linear Systems) Assume that we have a matrix
2
M Rm for which we would like to solve the linear system M x = y.
Moreover, assume that M is diagonal. Can you find an O(m) algorithm for
it? Now assume that M is banded with nonzero terms only within one band
of the main diagonal. Show that you can still solve the system in O(m) time,
albeit with slightly higher cost. Show that you can solve M x = y by processing
both the upper left and the lower right corner of the matrix simultaneously.
Problem 3.16 (Pair-HMM) Assume that we have a gene sequence which
is being transformed under mutation. In particular, assume that we have 4
symbols (A, C, G, T) and that for each symbol there is a probability that it is
changed to another symbol, that we insert a symbol, and that we will omit this
symbol [Wat99]. Compute the probability that we observe a sequence x given
an original sequence x . Next assume that we have a uniform distribution
over sequences. Compute the probability that two sequences arise from the
same ancestor.
Note: this type of problem is common when comparing the genomes of
different organisms, e.g. in the computation of phylogenetic trees.
Problem 3.17 (Gaussian Conditioning) Assume that (x, y) are jointly
normal with
x
y
x
y
xx xy
xy yy
(3.35)
(3.36)
Hint: expand p(x, y) in terms depending only on y and a multiplicative remainder which can be dropped since you need to normalize for p(y|x)
3.3 Applications
117
p(x, y). You will need to invert a 2x2 block matrix. Then perform quadratic
expansion to obtain linear and quadratic terms for a Gaussian model in y.
Problem 3.18 (Cumulative Distribution Function Networks) Marginalization
F (x) = maxy F (x, y). Conditioning F (y|x) (check this). [HF08] paper.
Problem 3.19 (Directed and Undirected Models) Directed and Undirected Models are not equivalent. Use the example from Kevin Murphy.
4
Undirected Graphical Models
120
2
1
3
5
2
5
1
1
6
9
8
directed graph cannot be acyclic (see also Problem 4.17 for an example).
Loosely speaking, the relationship between directed and undirected models
is that the former make a model of causal dependencies between random
variables whereas the latter only model correlations.
4.0.5 Definition
We begin by introducing some more graph-theoretic tools:
Definition 4.1 (Cliques) Denote by G(V, E) an undirected graph with vertices V and edges E. Then a clique c G is a subset of vertices Vc V with
all associated edges Ec E such that all vertices in c are fully connected. A
maximal clique is a clique which cannot be extended by adding more vertices.
Figure 4.1 provides an example of such graphs. As before in the case of directed models we associate with each vertex of the graph a random variable.
For a given graph G denote by C the set of all maximal cliques. In this case
we define
p(x) :=
1
Z
c (xc ) where Z :=
cC
X cC
c (xc )dx.
(4.1)
121
Theorem 4.2 (M
obius) Denote by g a real-valued function on X and denote by gA (x) the restriction of g onto the subset A via gA (x) = g(xA ) by
setting all coordinates of x not contained in A to 0. Then the following holds:
(1)|A\B| gB (x) g(x) =
A (x) =
BA
A (x)
(4.2)
A (x) =
A
A BA
(1)|A\B| .
gB (x)
B
AB
(1)
AB
(1)i
=
i=0
n
i
122
(4.3)
A (x) =
BA\{a,b}
Now note that that due to the Markov property (p(xa |xB , xb ) = p(xa |xB ))
p(xB , xa , xb )
p(xa |xB , xb )p(xB , xb )
= log
p(xB , xa )
p(xa |xB )p(xB )
p(xB , xb )
= log
= gB{b} (x) gB (x).
p(xB )
4.1 Examples
When modeling distributions over random variables we have three principal
strategies to keep the models simple.
We can make stringent conditional independence assumptions by means
of a suitable graph. This is the main point of the present chapter and we
discuss how to build such models and perform inference in them.
We can make assumptions of symmetry. For instance, if we have a set
of n random variables which depend on each other in a ring-wise fashion
(see Figure 4.2) we may make the assumption that the clique potentials
A (xA ) all take the same functional form. This is justified whenever there
is no specific property associated with a particular position on the ring.
123
Such a choice can significantly improve our estimates, since we only need
to estimate one potential A (xA ) instead of n separate potentials.
We can assume that the clique-potentials themselves are simple. For instance, we could assume that A (xA ) is slowly varying. This will become
the focus of our discussions when it comes to regularization and priors.
We will discuss the first and second of those modeling choices for a number
of common structures: chains, rings, and lattices. In the process of doing
so we will again encounter dynamic programming algorithms which are a
special case of the generalized distributed law. A more detailed discussion
of the latter will follow in Section 4.3.
Chains
Rings
Lattices
1,2,3
1,3
1,3,4
1,4
1,4,5
1,5
7
1,7,8
1,7
1,6,7
1,6
1,5,6
3,6
3,5,6
1,2
4,8
5,6
5,6,7
2,3,4,6
6
4,8
2,3,4,6
6
6
6,9
3,6
3,5,6
5,6
5,6,7
6,7
6,7,9
124
125
Problem 4.6 (Page Rank) Random surfer visits each link uniformly. With
given probability resets. Speed of convergence (find eigenvalue).
Problem 4.7 (k-means with Conjugate Prior) Figure 3.5 on the right.
Problem 4.8 (User behavior in search engine) Let us model the click
behavior of a user when dealing with the results of a search engine.
v
vi
ci
ui
vi+1
10
126
symbols (A, C, G, T) and that for each symbol there is a probability that it is
changed to another symbol, that we insert a symbol, and that we will omit this
symbol [Wat99]. Compute the probability that we observe a sequence x given
an original sequence x . Next assume that we have a uniform distribution
over sequences. Compute the probability that two sequences arise from the
same ancestor.
Note: this type of problem is common when comparing the genomes of
different organisms, e.g. in the computation of phylogenetic trees.
Problem 4.15 (Gaussian Conditioning) Assume that (x, y) are jointly
normal with
x
y
x
y
xx xy
xy yy
(4.4)
(4.5)
Hint: expand p(x, y) in terms depending only on y and a multiplicative remainder which can be dropped since you need to normalize for p(y|x)
p(x, y). You will need to invert a 2x2 block matrix. Then perform quadratic
expansion to obtain linear and quadratic terms for a Gaussian model in y.
Problem 4.16 (Cumulative Distribution Function Networks) Marginalization
F (x) = maxy F (x, y). Conditioning F (y|x) (check this). [HF08] paper.
Problem 4.17 (Directed and Undirected Models) Directed and Undirected Models are not equivalent. Use the example from Kevin Murphy.
5
Optimization
(5.1)
l(f (xi ), yi ).
(5.2)
i=1
Here xi are the training instances and yi are the corresponding labels. l the
loss function measures the discrepancy between y and the predictions f (xi ).
Finding the optimal f involves solving an optimization problem.
This chapter provides a self-contained overview of some basic concepts and
tools from optimization, especially geared towards solving machine learning
problems. In terms of concepts, we will cover topics related to convexity,
duality theory, and Lagrange multipliers. In terms of tools, we will cover
a variety of optimization algorithms including gradient descent, stochastic
gradient descent, Newton method, and Quasi-Newton methods. We will also
look at some specialized algorithms tailored towards solving Linear Programming and Quadratic Programming problems which often arise in machine
learning problems.
5.1 Preliminaries
Minimizing an arbitrary function is, in general, very difficult, but if the objective function to be minimized is convex then things become considerably
simpler. As we will see shortly, the key advantage of dealing with convex
functions is that a local optima is also the global optima. Therefore, well
developed tools exist to find the global minima of a convex function. Consequently, many machine learning algorithms are now formulated in terms of
convex optimization problems. We briefly review the concept of convex sets
and functions in this section.
127
128
5 Optimization
Fig. 5.1. The convex set (left) contains the line joining any two points that belong
to the set. A non-convex set (right) does not satisfy this property.
i i
Definition 5.2 (Convex Hull) The convex hull, conv(X), of a finite subset X = {x1 , . . . , xn } of Rn consists of all convex combinations of x1 , . . . , xn .
(5.3)
(5.4)
5.1 Preliminaries
129
(5.5)
whenever x = x .
1000
1.5
800
1.0
0.5
f(x)
f(x)
600
400
0.0
0.5
200
1.0
0
6
0
x
1.5 3
0
x
Fig. 5.2. A convex function (left) satisfies (5.4); the shaded region denotes its epigraph. A nonconvex function (right) does not satisfy (5.4).
(5.6)
In other words, the first order Taylor approximation lower bounds the convex
function universally (see Figure 5.4).
If f is twice differentiable, then f is convex if, and only if, its Hessian is
positive semi-definite, that is,
2 f (x)
0.
(5.7)
For twice differentiable strictly convex functions, the Hessian matrix is positive definite, that is, 2 f (x)
0. We briefly summarize some operations
which preserve convexity:
Addition
Scaling
Affine Transform
Adding a Linear Function
Pointwise Maximum
Scalar Composition
130
5 Optimization
3
18
16
14
12
10
8
6
4
2
0
2
1
0
-1
3
-2
2
1
-3
-2
0
-1
-3
3
-1
-2
-3
-1
1
-2
3 -3
Fig. 5.3. Left: Convex Function in two variables. Right: the corresponding convex
below-sets {x|f (x) c}, for different values of c.
(5.8)
is convex.
Proof For any x, x Xc , we have f (x), f (x ) c. Moreover, since f is
convex, we also have
f (x + (1 )x ) f (x) + (1 )f (x ) c for all 0 < < 1.
(5.9)
5.1 Preliminaries
131
(5.10)
= x x, f (x) < 0,
=0
which shows that for small values of we have f (z()) < f (x), thus showing
that x is not optimal.
The reverse implication follows from (5.6) by noting that f (x ) f (x),
whenever (5.10) holds.
One way to ensure that (5.10) holds is to set f (x) = 0. In other words,
minimizing a convex function is equivalent to finding a x such that f (x) =
0. Therefore, the first order conditions are both necessary and sufficient
when minimizing a convex function.
5.1.3 Subgradients
So far, we worked with differentiable convex functions. The subgradient is a
generalization of gradients appropriate for convex functions, including those
which are not necessarily smooth.
132
5 Optimization
Definition 5.7 (Subgradient) Suppose x is a point where a convex function f is finite. Then a subgradient is the normal vector of any tangential
supporting hyperplane of f at x. Formally is called a subgradient of f at
x if, and only if,
f (x ) f (x) + x x, for all x .
(5.11)
The set of all subgradients at a point is called the subdifferential, and is denoted by x f (x). If this set is not empty then f is said to be subdifferentiable
at x. On the other hand, if this set is a singleton then, the function is said
to be differentiable at x. In this case we use f (x) to denote the gradient
of f . Convex functions are subdifferentiable everywhere in their domain. We
now state some simple rules of subgradient calculus:
Addition
Scaling
Affine Transform
Pointwise Maximum
I.
(5.12)
133
f (x ) f (x) + x x, +
x x 2 x, x and f (x). (5.13)
2
The right hand side can be minimized by setting the gradient with respect
to x equal to zero (since the RHS is a convex function of w , Lemma 5.6
applies). This yields x = x 1 . Substituting this back into (5.13) yields
1
2 x, x and f (x).
(5.14)
2
In particular, by setting x = x , the global minimizer of f , one obtains
f (x ) f (x)
f (x) f (x )
x and f (x).
(5.15)
x, x .
(5.16)
If f has a Lipschitz continuous gradient with modulus L, then one can show
(Exercise 5.6) that
L
x x 2 f (x) x, x .
(5.17)
2
Furthermore, if f is twice differentiable, then there is an equivalent definition: f has a Lipschitz continuous gradient if there exists a L such that
f (x ) x x, f (x) +
LI
2 f (x).
(5.18)
134
5 Optimization
Fig. 5.4. A convex function is always lower bounded by its first order Taylor approximation. This is true even if the function is not differentiable (see Figure 5.5)
5
4
3
2
1
0
14
135
(5.19)
(5.20)
(5.21)
(5.22)
If the objective function is convex, then the one dimensional function obtained by restricting
it along the search direction is also convex (Exercise 5.7).
136
5 Optimization
(U L) J (U )
,
2t
(5.23)
for all w (at , bt ). In other words, to find an -accurate solution, that is,
J(w ) J(w ) we only need log(U L) + log J (U ) + log(1/ ) < t iterations. An algorithm which converges to an accurate solution in O(log(1/ ))
iterations is said to be linearly convergent.
For multi-dimensional objective functions, one cannot rely on the monotonicity property of the gradient. Therefore, one needs more sophisticated
optimization algorithms, some of which we now describe.
(5.24)
where the scalar t minimizes the one dimensional objective function J(wt
J(wt )) with respect to . See Algorithm 5.2 for details.
In order to analyze the convergence behavior of the gradient descent procedure let us assume that J is strongly convex with modulus of strong convexity . Furthermore, we assume that J has a Lipschitz continuous gradient
with modulus L, and that an exact line search is use to find t . For such functions, (5.15) implies that J(wt ) 2 2(J(wt )J(w )). Therefore, ensuring that J(wt ) < is sufficient to ensure that J(wt ) J(w ) < 2 /2. In
137
1
L
J(wt )
Lt2
J(wt )
2
J(wt+1 ).
shows that
1
J(wt )
2L
J(wt+1 ).
Combining this with J(wt ) 2 2(J(wt ) J(w )), one can write
1
(J(wt ) J(w )) J(wt+1 ) J(w ).
L
Letting c := 1 L , and applying the above equation recursively we obtain
ct (J(w0 ) J(w )) J(wt ) J(w ),
which shows that J(wt ) J(w )
after at most
(5.25)
In fact, we can rewrite any convex quadratic function J(w) = w Aw + b w + d in the form
(5.25)
138
5 Optimization
Fig. 5.6. Convergence of gradient descent with exact line search on two quadratic
problems (5.25). The problem on the left is ill-conditioned, whereas the problem
on the right is well-conditioned. We plot the contours of the objective function,
and the steps taken by gradient descent. As can be seen gradient descent converges
fast on the well conditioned problem, while it zigzags and takes many iterations to
converge on the ill-conditioned problem.
(5.26)
139
(5.27)
(5.28)
(5.29)
for some constant C > 0. We now show that Newtons method exhibits
quadratic convergence close to the optimum.
Theorem 5.10 (Quadratic convergence of Newton Method) Suppose
J is twice differentiable, strongly convex, and the Hessian of J is bounded and
Lipschitz continuous in a neighborhood of the solution w . Furthermore, assume that 2 J(w)1 M . The iterations wt+1 = wt 2 J(wt )1 J(wt )
converge quadratically to w , the minimizer of J.
Proof First notice that
1
J(wt ) J(w ) =
0
(5.30)
140
5 Optimization
Next using the fact that 2 J(wt ) is invertible and the gradient vanishes at
the optimum (J(w ) = 0), write
wt+1 w = wt w 2 J(wt )1 J(wt )
= 2 J(wt )1 [2 J(wt )(wt w ) (J(wt ) J(w ))]. (5.31)
Using (5.31), (5.30), and the Lipschitz continuity of 2 J
2 J(wt )(wt w ) (J(wt ) J(w ))
1
=
0
1
(wt w ) dt
wt w
1
2
Lt dt =
0
L
wt w 2 .
2
(5.32)
L 2 1
J (wt ) wt w
2
LM
wt w 2 .
2
The Newtons method as we described it suffers from two major problems. First, it applies only to twice differentiable, strictly convex functions.
Second, it involves computing and inverting of the d d Hessian matrix at
every iteration, thus making it computationally very expensive. Although
Newton method can be extended to deal with positive semi-definite Hessian
matrices, the computational burden often makes it unsuitable for large scale
applications. In such cases one resorts to Quasi-Newton methods, which we
now describe.
5.2.3.1 Quasi-Newton Methods
Unlike the Newton method, which computes the Hessian of the objective
function at every iteration, quasi-Newton methods never compute the Hessian; they approximate it from past gradients. Since they do not require
the objective function to be twice differentiable, quasi-Newton methods are
much more widely applicable. They are widely regarded as the workhorses of
smooth nonlinear optimization due to their combination of computational efficiency and good asymptotic convergence. The most popular quasi-Newton
algorithm is BFGS, named after its discoverers Broyde, Fletcher, Goldfarb,
141
1200
1000
800
600
400
200
0
200
400 6
Fig. 5.7. The blue solid line depicts the one dimensional convex function f (x) =
x4 + 20x2 + x. The green dotted-dashed line represents the first order Taylor approximation to f (x), while the red dashed line represents the second order Taylor
approximation, both evaluated at x = 2.
and Shanno. In this section we will describe BFGS and its limited memory
counterpart L-BFGS.
Suppose we are given a smooth (not necessarily strictly) convex objective
function J : Rd R and a current iterate wt Rd . Just like the Newton
method, BFGS forms a local quadratic model of the objective function, J:
1
Qt (p) := J(wt ) + J(wt ), p + p Ht p.
2
(5.33)
Unlike the Newton method which uses the computed Hessian (5.26) to build
its quadratic model, BFGS uses the matrix Ht
0, which is a positivedefinite estimate of the Hessian. As before J denotes the gradient of J. A
quasi-Newton direction of descent is found by minimizing Qt (p):
pt = Ht1 J(wt ).
(5.34)
The step size t > 0 is found by a line search obeying the Wolfe conditions:
J(wt+1 ) J(wt ) + c1 t J(wt ) pt
J(wt+1 ) pt c2 J(wt ) pt
(sufficient decrease)
(curvature)
(5.35)
(5.36)
142
5 Optimization
(5.37)
(5.39)
which implies that Qt+1 (0) = J(wt+1 ), and hence our second condition
is automatically satisfied. In order to satisfy our first condition, we require
Qt+1 (t pt ) = J(wt+1 ) t Ht+1 pt = J(wt ).
(5.40)
(5.41)
(5.42)
(5.43)
s. t. B = B
and Byt = st .
(5.44)
(5.45)
143
if t = 0 : Bt :=
st yt
I
yt yt
t = (st yt )1
Bt+1 = (I t st yt )Bt (I t yt st ) + t st st
t=t+1
end while
Return: wt
(5.46)
(5.47)
(5.48)
144
5 Optimization
pt Ax
pt =
pt Apt
pt b
pt .
pt Apt
(5.49)
The advantage of using the conjugate directions now becomes apparent. The
coefficients i are now expressed in terms of a known vector b, which implies
that if we if we had a cheap way to compute the conjugate directions, then
we can solve (5.46) efficiently. This following theorem shows how this idea
can be extended to minimize the quadratic function (5.47) sequentially.
Theorem 5.12 Let {p0 , . . . , pn1 } denote a set of conjugate directions. For
any x0 Rn , the sequence {xt } generated by
xt+1 = xt + t pt ,
(5.50)
with
t =
gt pt
,
pt Apt
(5.51)
(5.52)
145
Proof Let x denote the minimizer of (5.47). Since the pi s form a basis
x x0 = 0 p0 + . . . + n1 pn1 ,
for some scalars i . Our proof strategy will be to show that the coefficients
t coincide with t defined in (5.51). Towards this end we premultiply with
pt A and use conjugacy to obtain
t =
pt A(x xt )
.
pt Apt
(5.53)
On the other hand, following the iterative process (5.50) from x0 until xt
yields
xt x0 = 0 p0 + . . . + t1 pt1 .
Again premultiplying with pt A and using conjugacy
pt A(xt x0 ) = 0.
(5.54)
pt A(x xt )
g pt
= t
,
pt Apt
pt Apt
(5.55)
Axt
= p j gt
gt pt
Apt b
pt Apt
pj Apt
pt Apt
gt pt .
For j = t, both terms cancel out, while for j < t both terms vanish due
to the induction hypothesis as well as the fact that the pj are conjugate
directions.
In a nutshell, the above theorem already contains the conjugate gradient
descent algorithm: At each step, we perform gradient descent with respect
to one of the conjugate directions, which means that after n steps we will
reach the minimum. We still need a way to generate the conjugate directions.
It turns out that we can generate them on the fly efficiently.
146
5 Optimization
(5.56)
gt pt
pt Apt
(5.57)
t =
(5.58)
gt+1 Apt
pt Apt
(5.59)
t+1 =
Note that the scalar t+1 is found by the requirement that pt and pt+1 must
be conjugate directions. The following theorem asserts that the directions
pt are indeed conjugate directions:
Theorem 5.13 Suppose the t-th iterate generated by the conjugate gradient
method (Equations (5.56) to (5.59)) is not the solution point x , then the
following properties hold:
span{g0 , g1 , . . . , gt } = span{g0 , Ag0 , . . . , At g0 }.
t
(5.60)
(5.61)
(5.62)
Proof The proof is by induction. Clearly (5.60), (5.61), and (5.62) hold
when t = 0. Assuming that they are true for some t, we prove that they
continue to hold for t + 1. Recall that gt+1 = Axt+1 b. Using (5.50) and
(5.51) one can conclude that
gt+1 = Axt + t Apt b = gt + t Apt .
By our induction hypothesis gt span{g0 , Ag0 , . . . , At g0 }, while Apt
span{Ag0 , A2 g0 , . . . , At+1 g0 }. Combining the two it is easy to see that gt+1
span{g0 , Ag0 , . . . , At+1 g0 }. On the other hand, (5.52) implies that gt+1 is orthogonal to {p0 , p1 , . . . , pt }. Therefore, gt+1
/ span{p0 , p1 , . . . , pt }, thus our
induction assumption implies that gt+1
/ span{g0 , Ag0 , . . . , At g0 }. This allows us to conclude that span{g0 , g1 , . . . , gt+1 } = span{g0 , Ag0 , . . . , At+1 g0 }.
The proof of (5.61) is immediate by using (5.58) and (5.60).
To show (5.62) we use (5.58) to write
pt+1 Apj = gt+1 Apj + t+1 pt Apj
By the definition of t+1 (5.59) the above expression vanishes for j = t. For
j < t, the first term is zero because Apj span{p0 , p1 , . . . , pj+1 }, a subspace
orthogonal to gt+1 by (5.52). The induction hypothesis guarantees that the
second term is zero.
147
gt gt
.
pt Apt
(5.63)
gt+1 gt+1
.
gt gt
(5.64)
Fletcher-Reeves
g t pt
Kt pt
and t =
gt+1 Kt pt
pt Kt pt
Polak-Ribi`ere
gt+1 gt+1
.
gt gt
148
5 Optimization
w.
(5.65)
(5.66)
t1
Given iterates {wi }i=0
, the cutting plane method minimizes JtCP to obtain
the next iterate wt :
(5.67)
This iteratively refines the piecewise linear lower bound J CP and allows us
to get close to the minimum of J (see Figure 5.8 for an illustration).
If w denotes the minimizer of J, then clearly each J(wi ) J(w ) and
hence min0it J(wi ) J(w ). On the other hand, since J JtCP it follows that J(w ) JtCP (wt ). In other words, J(w ) is sandwiched between
min0it J(wi ) and JtCP (wt ) (see Figure 5.9 for an illustration). The cutting
plane method monitors the monotonically decreasing quantity
t
(5.68)
149
Fig. 5.8. A convex function (blue solid curve) is bounded from below by its linearizations (dashed lines). The gray area indicates the piecewise linear lower bound
obtained by using the linearizations. We depict a few iterations of the cutting plane
method. At each iteration the piecewise linear lower bound is minimized and a new
linearization is added at the minimizer (red rectangle). As can be seen, adding more
linearizations improves the lower bound.
(e.g., JtCP (w) in (5.66)) with a prox-function (i.e., proximity control function) which prevents overly large steps in the iterates [Kiw90]. Roughly
speaking, there are 3 popular types of bundle methods, namely, proximal
[Kiw90], trust region [SZ92], and level set [LNN95]. All three versions use
2
1
as their prox-function, but differ in the way they compute the new
2
iterate:
t
ww
t1 2 + JtCP (w)},
2
w
1
ww
t1 2 t },
trust region: wt := argmin{JtCP (w) |
2
w
1
t1 2 | JtCP (w) t },
level set: wt := argmin{ w w
2
w
proximal:
wt := argmin{
(5.69)
(5.70)
(5.71)
where w
t1 is the current prox-center, and t , t , and t are positive tradeoff parameters of the stabilization. Although (5.69) can be shown to be
equivalent to (5.70) for appropriately chosen t and t , tuning t is rather
difficult while a trust region approach can be used for automatically tuning
150
5 Optimization
Fig. 5.9. A convex function (blue solid curve) with four linearizations evaluated at
four different locations (magenta circles). The approximation gap 3 at the end of
fourth iteration is indicated by the height of the cyan horizontal band i.e., difference
between lowest value of J(w) evaluated so far and the minimum of J4CP (w) (red
diamond).
(5.72a)
s. t. ci (x) 0 for i I
(5.72b)
ei (x) = 0 for i E
(5.72c)
where both ci and ei are convex functions. We say that x is feasible if and
only if it satisfies the constraints, that is, ci (x) 0 for i I and ei (x) = 0
for i E.
Recall that x is the minimizer of an unconstrained problem if and only
if f (x) = 0 (see Lemma 5.6). Unfortunately, when constraints are present
one cannot use this simple characterization of the solution. For instance, the
x at which f (x) = 0 may not be a feasible point. To illustrate, consider
151
(5.73a)
Clearly,
1 2
2x
(5.73b)
14
12
10
f(x)
8
6
4
2
0
6
0
x
i ci (x) +
iI
i ei (x)
(5.74)
iE
152
5 Optimization
max L(x, , ) =
otherwise.
0,
0,
Proof First assume that x is feasible, that is, ci (x) 0 for i I and
ei (x) = 0 for i E. Since i 0 we have
i ei (x) 0,
i ci (x) +
(5.75)
iE
iI
0,
0,
i ci (x) +
iI
i ei (x) = f (x)
iE
(5.76)
for 0 and , then one can prove the following property, which is often
called as weak duality.
Theorem 5.15 (Weak Duality) The Lagrange dual function (5.76) satisfies
g(, ) f (x)
for all feasible x and 0 and . In particular
D := max min L(x, , ) min max L(x, , ) = P .
0,
0,
i ci (x) +
iI
iE
(5.77)
153
Therefore
x
i ei (x) f (x)
i ci (x) +
iE
iI
for all feasible x and 0 and . In particular, one can choose x to be the
minimizer of (5.72) and 0 and to be maximizers of g(, ) to obtain
(5.77).
Weak duality holds for any arbitrary function, not-necessarily convex. When
the objective function and constraints are convex, and certain technical conditions hold then we can say more.
Theorem 5.16 (Strong Duality) BUGBUG
The proof of the above theorem is quite technical and can be found in
any standard reference (e.g., [BV04]). Therefore we will omit the proof and
proceed to discuss various implications of strong duality. First note that
strong duality implies
min max L(x, , ) = max min L(x, , ).
x
0,
0,
(5.78)
In other words, one can switch the order of minimization over x with maximization over and . This is called the saddle point property of convex
functions.
Suppose the primal and dual optimal values are attained at x and ( , )
respectively, and consider the following line of argument:
f (x ) = g( , )
(5.79a)
i ci (x) +
= min f (x) +
x
iI
f (x ) +
i ej (x)
i ci (x ) +
iI
(5.79b)
iE
i ei (x )
(5.79c)
iE
f (x ).
(5.79d)
i ei (x ) = 0.
iE
154
5 Optimization
i ci (x ) +
f (x ) +
iE
iI
i I
(5.80a)
ej (x ) = 0 i E
(5.80b)
(5.80c)
)=0
(5.80d)
i ei (x ) = 0.
(5.80e)
i ci (x
f (x ) +
i ci (x ) +
iI
iE
The above conditions are called the KKT conditions. If the primal problem
is convex, then the KKT conditions are both necessary and sufficient. In
satisfy (5.80) then x
are primal and
other words, if x
and (
, )
and (
, )
dual optimal with zero duality gap. To see this note that the first conditions
show that x
is feasible. Since i 0, L(x, , ) is convex in x. Finally the
last condition states that x
maximizes L(x, , ). Since
i ci (
x) = 0 and
ej (
x) = 0, we have
= L(
g(
, )
x,
, )
n
i ci (x ) +
= f (
x) +
i=1
j ej (x )
j=1
= f (
x).
5.3.2 Linear and Quadratic Programs
So far we discussed general constrained optimization problems. Many machine learning problems have special structure and can therefore be reduced
to a linear or quadratic program. We discuss the implications of duality for
these class of problems.
An optimization problem with a linear objective function and (both equality and inequality) linear constraints is said to be a linear program (LP). A
canonical linear program is of the following form:
min c x
(5.81a)
s. t. Ax = b, x 0.
(5.81b)
155
(5.82a)
s. t. Ax b,
(5.82b)
(5.83a)
s. t. Ax = b, 0.
(5.83b)
Next, we split x into its positive and negative parts x+ and x respectively
by setting x+
i = max(0, xi ) and xi = max(0, xi ). Using these new variables
we rewrite (5.83) as
+
c
x
min
(5.84a)
c
x
x
0
+
+
x
x
s. t. A A I x = b, x 0,
(5.84b)
(5.85)
Taking gradients with respect to the primal and dual variables and setting
them to zero obtains
A +s=c
(5.86a)
Ax = b
(5.86b)
s x=0
(5.86c)
(5.86d)
s 0.
(5.86e)
Condition (5.86c) can be simplified by noting that both x and s are constrained to be non-negative, therefore s x = 0 if, and only if, si xi = 0 for
i = 1, . . . , n.
156
5 Optimization
Substituting (5.86a) into the objective of (5.81), and using (5.86b) and
(5.86c) one can eliminate the primal variable x to obtain the following dual
LP
max b
(5.87a)
,s
s.t. A + s = c, 0, s 0.
(5.87b)
b
0
s.t.
,s
s
I
(5.88a)
= c,
0.
(5.88b)
(5.89b)
ai x bi for i I
(5.89c)
min
x
(5.89a)
min
x
(5.90a)
(5.90b)
(5.91)
157
To find the saddle point of the Lagrangian we take gradients with respect
to x and and set them to zero. This obtains
Gx + d A = 0
Ax = b.
Putting these two conditions together yields the following linear system of
equations
G A
A
0
d
b
1
m
l(f (xi ), yi ).
i=1
Classical optimization techniques must compute this sum in its entirety for
each evaluation of the objective, respectively its gradient. As available data
sets grow ever larger, such batch optimizers therefore become increasingly
inefficient. They are also ill-suited for the incremental setting, where partial
data must be modeled as it arrives.
Stochastic gradient-based methods, by contrast, work with gradient estimates obtained from small subsamples (mini-batches) of training data. This
can greatly reduce computational requirements: on large, redundant data
sets, simple stochastic gradient descent routinely outperforms sophisticated
second-order batch methods by orders of magnitude.
The key idea here is that J(w) is replaced by an instantaneous estimate
Jt which is computed from a mini-batch of size k comprising of a subset of
points (xti , yit ) with i = 1, . . . , k drawn from the dataset:
Jt (w) = (w) +
1
k
(5.92)
158
5 Optimization
+t
(5.93)
converges to the true minimizer of J(w) if the step size t decays as O(1/ t).
For instance, one could set
t =
,
+t
(5.94)
t =
.
(5.95)
+t
The free parameter > 0 can be tuned as described above.
159
If (w) is strongly convex with modulus , then dividing the step size t
by yields good practical performance.
Finally, many sophisticated step size adaptation algorithms such as SMD
have been also been proposed for automatically tuning t .
5.5.2 Randomization
randomized maximization
(5.96)
where f and g are convex functions. Clearly, J is not convex, but there
exists a reasonably simple algorithm namely the Concave-Convex Procedure
(CCP) for finding a local minima of J. The basic idea is simple: In the
tth iteration replace g by its first order Taylor expansion at wt , that is,
g(wt ) + w wt , g(wt ) and minimize
Jt (w) = f (w) g(wt ) w wt , g(wt ) .
(5.97)
(5.98)
160
5 Optimization
10
200
20
150
30
100
40
50
50
60
0
70
801.0
1.5
2.0
2.5
3.0
3.5
4.0
501.0
1.5
2.0
2.5
3.0
3.5
4.0
Fig. 5.11. Given the function on the left we decompose it into the difference of two
convex functions depicted on the right panel. The CCP algorithm generates iterates
by matching points on the two convex curves which have the same tangent vectors.
As can be seen, the iterates approach the solution x = 2.0.
161
6
Conditional Densities
6.1.3 Optimization
- distribution over natural parameter (for posterior) - newton method and
bundle method
6.2.2 Optimization
Newton method why the posterior isnt nice
6.3 Regression
6.3.1 Conditionally Normal Models
fixed variance
163
164
6 Conditional Densities
165
Definition
Discuss that they are modeling joint distribution p(x, y)
The way they predict is by marginalizing out x
Why they are wasteful and why CRFs generally outperform them
6.8.1 Optimization
issues in optimization (blows up with number of classes). structure is not
there. can we do better?
166
Problems
Problem 6.1 Poisson models
Problem 6.2 Bayes Committee Machine
Problem 6.3 Newton / CG approach
6 Conditional Densities
7
Kernels and Function Spaces
7.1 Kernels
7.1.1 Feature Maps
give examples, linear classifier, nonlinear ones with r2-r3 map
7.2 Algorithms
7.2.1 Kernel Perceptron
7.2.2 Trivial Classifier
7.2.3 Kernel Principal Component Analysis
7.3 Reproducing Kernel Hilbert Spaces
7.3.1 Hilbert Spaces
evaluation functionals, inner products
7.3.3 Regularization
Representer theorem, regularization
167
168
8
Linear Models
A hyperplane in a dot product space H is described by the set
{x H| w, x + b = 0},
(8.1)
i=1,...,m
| w, xi + b |
.
w
(8.2)
i=1,...m
170
8 Linear Models
max
w,b
(8.3a)
(8.3b)
or equivalently
1
w 2
w,b 2
s.t. yi ( w, xi + b) 1 for all i.
min
(8.4a)
(8.4b)
This is a constrained convex optimization problem with a quadratic objective function and linear constraints (see Section 5.3). In deriving (8.4) we
implicitly assumed that the data is linearly separable, that is, there is a
hyperplane which correctly classifies the training data. Such a classifier is
called a hard margin classifier. If the data is not linearly separable, then
(8.4) does not have a solution. To deal with this situation we introduce
non-negative slack variables i to relax the constraints:
yi ( w, xi + b) 1 i .
Given any w and b the constraints can now be satisfied by making i large
enough. This renders the whole optimization problem useless. Therefore, one
has to penalize large i . This is done via the following modified optimization
problem:
min
w,b,
1
w
2
C
m
(8.5a)
i=1
(8.5b)
(8.5c)
1
w
2
C
m
i=1
i (1 i yi ( w, xi + b))
i +
i=1
i i .
i=1
171
w L = w
i yi xi = 0
(8.6)
i=1
m
b L =
i yi = 0
(8.7)
i=1
i L =
C
i i = 0.
m
(8.8)
Substituting (8.6), (8.7), and (8.8) into the Lagrangian and simplifying yields
the dual objective function:
1
2
yi yj i j xi , xj +
i,j
i ,
(8.9)
i=1
1
min
yi yj i j xi , xj
i,j
(8.10a)
i=1
s.t.
i yi = 0
(8.10b)
C
.
m
(8.10c)
i=1
0 i
(8.11a)
(8.11b)
(8.11c)
172
8 Linear Models
w=
i yi (xi ),
i=1
w, x + b =
i yi k(xi , x) + b.
(8.12)
i=1
173
optimization problem:
1
min
w
w,b 2
C
+
m
max(0, 1 yi ( w, xi + b)).
(8.13)
i=1
(8.14)
In the later part of the chapter generalizations of the binary hinge loss will
be used to extend the support vector machinery to deal with a large class of
problems such as novelty detection, multiclass classification, and structured
prediction.
8.1.2 An Exponential Family Interpretation
Our motivating arguments for deriving the SVM algorithm have largely
been geometric. We now show that an equally elegant probabilistic interpretation also exists. Assuming that the training set {(x1 , y1 ), . . . , (xm , ym )}
was drawn iid from some underlying distribution, and using the Bayes rule
(1.15) one can write the likelihood
m
(8.15)
(8.16)
i=1
log p(|X, Y ) =
i=1
In the absence of any prior knowledge about the data, we choose a zero
mean unit variance isotropic normal for p(). This yields
log p(|X, Y ) =
m
2
(8.17)
i=1
(8.18)
174
8 Linear Models
Of course, our aim is not just to maximize p(yi |xi , ) but also to ensure
that p(y|xi , ) is small for all y = yi . This, for instance, can be achieved by
requiring
p(yi |xi , )
, for all y = yi and some 1.
p(y|xi , )
(8.19)
As we saw in Section 2.3 exponential families of distributions are rather flexible modeling tools. We could, for instance, model p(yi |xi , ) as a conditional
exponential family distribution. Recall the definition:
p(y|x, ) = exp ( (x, y), g(|x)) .
(8.20)
Here (x, y) is a joint feature map which depends on both the input data
x and the label y, while g(|x) is a log-partition function. Now (8.19) boils
down to
p(yi |xi , )
= exp
maxy=yi p(y|xi , )
y=yi
y
2 (x),
(8.21)
yi
yi
(xi )
(xi ), = yi (xi ), 1.
2
2
(8.22)
By replacing log p(yi |xi , ) in (8.17) with the condition (8.22) we obtain
the following objective function:
min
s.t.
1
2
2
yi (xi ), 1 for all i,
(8.23a)
(8.23b)
which recovers (8.4), but without the bias b. As before, we can replace (8.22)
by a linear penalty for constraint violation in order to recover (8.5).
175
s.t.
1
2
B B
HBB HB B
HBB
HB B
B
B
B B
B B y = 0
C
for all i B.
0 i
m
(8.24a)
(8.24b)
(8.24c)
HBB HB B
is a permutation of the matrix H. By eliminating
HBB
HB B
constant terms and rearranging, one can simplify the above problem to
Here,
1
HBB B + B (HBB
B
e)
B
2 B
s.t. B yB = B yB
C
for all i B.
0 i
m
min
(8.25a)
(8.25b)
(8.25c)
An extreme case of a decomposition method is the Sequential Minimal Optimization (SMO) algorithm of Platt [Pla99], which updates only two coefficients per iteration. The advantage of this strategy as we will see below is
that the resultant sub-problem can be solved analytically. Without loss of
generality let B = {i, j}, and define s = yi /yj , ci cj = (HBB
B
e)
and d = (B yB /yj ). Then (8.25) specializes to
1
(Hii i2 + Hjj j2 + 2Hij j i ) + ci i + cj j
i ,j 2
s.t. si + j = d
C
0 i , j .
m
min
(8.26a)
(8.26b)
(8.26c)
max(0,
max(0,
H=
C
d m
s
d
s)
(8.27)
otherwise
C d
min( m
, s)
C
C d m
min( m
, s
if s > 0
if s > 0
)
otherwise,
(8.28)
176
8 Linear Models
(8.29)
(8.30)
if < 0
otherwise.
(8.31)
(8.32)
177
C
i ) = 0,
m
(8.33)
(8.34a)
(8.34b)
C
.
m
(8.34c)
Iup = {i : i <
Idown
(8.35a)
(8.35b)
iIdown
(8.36)
Therefore, a natural stopping criterion is to stop when the KKT gap falls
below a desired tolerance , that is,
m() M () + .
(8.37)
Finally, we turn our attention to the issue of working set selection. The
first order approximation to the objective function J() can be written as
J( + d) J() + J() d.
Since we are only interested in updating coefficients in the working set B
we set d = dB 0 , in which case we can rewrite the above first order
178
8 Linear Models
approximation as
J()B dB J( + d) J().
From among all possible directions dB we wish to choose one which decreases
the objective function the most while maintaining feasibility. This is best
expressed as the following optimization problem:
min J()B dB
(8.38a)
s.t. yB dB = 0
(8.38b)
dB
di 0 if i = 0 and i B
C
di 0 if i =
and i B
m
1 di 1.
(8.38c)
(8.38d)
(8.38e)
(8.39a)
s.t. yi di + yj dj = 0
(8.39b)
i,j
dk 0 if k = 0 and k {i, j}
C
dk 0 if k =
and k {i, j}
m
1 dk 1 for k {i, j}.
(8.39c)
(8.39d)
(8.39e)
At first glance, it seems that choosing the optimal i and j from the set
{1, . . . , m}{1, . . . m} requires O(m2 ) effort. We now show that O(m) effort
suffices.
Define new variables dk = yk dk for k {i, j}, and use the observation
yk {1} to rewrite the objective function as
(yi J()i + yj J()j ) dj .
Consider the case J()i yi J()j yj . Because of the constraints
(8.39c) and (8.39d) if we choose i Iup and j Idown , then dj = 1 and
di = 1 is feasible and the objective function attains a negative value. For
all other choices of i and j (i, j Iup ; i, j Idown ; i Idown and j Iup )
the objective function value of 0 is attained by setting di = dj = 0. The
case J()j yj J()i yi is analogous. In summary, the optimization
179
iIup ,jIdown
jIdown
which clearly can be solved in O(m) time. Comparison with (8.36) shows
that at every iteration of SMO we choose to update coefficients i and j
which maximally violate the KKT conditions.
w,b,,
1
w
2
1
m
(8.40a)
i=1
(8.40b)
i 0, and 0.
(8.40c)
1
m
i ( i yi ( w, xi + b))
i +
i=1
i=1
i i .
i=1
Taking gradients with respect to the primal variables and setting them to 0
yields
m
i yi x i = w
(8.41)
i=1
m
i yi = 0
(8.42)
i=1
1
m
(8.43)
i = .
(8.44)
i + i =
m
i=1
180
8 Linear Models
1
2
yi yj i j xi , xj
(8.45a)
i,j
s.t.
i yi = 0
(8.45b)
1
m
(8.45c)
i .
(8.45d)
i=1
0 i
m
i=1
The following theorems, which we state without proof, explain the significance of and the connection of -SVM and the soft margin formulation.
Theorem 8.2 Suppose we run -SVM with kernel k on some data and
obtain > 0. Then
(i) is an upper bound on the fraction of margin errors, that is points
for which yi ( w, xi + bi ) < .
(ii) is a lower bound on the fraction of support vectors, that is points
for which yi ( w, xi + bi ) = .
(iii) Suppose the data (X, Y ) were generated iid from a distribution p(x, y)
such that neither p(x, y = +1) or p(x, y = 1) contain any discrete
components. Moreover, assume that the kernel k is analytic and nonconstant. With probability 1, asympotically, equals both the fraction
of support vectors and fraction of margin errors.
Theorem 8.3 If (8.40) leads to a decision function with > 0, then (8.5)
with C = 1 leads to the same decision function.
8.2 Support Vector Regression
As opposed to classification where the labels yi are binary valued, in regression they are real valued. Given a tolerance , our aim here is to find a
hyperplane parameterized by (w, b) such that
|yi ( w, xi + b)| .
(8.46)
181
In other words, we want to find a hyperplane such that all the training data
lies within an tube around the hyperplane. We may not always be able to
find such a hyperplane, hence we relax the above condition by introducing
slack variables i+ and i and write the corresponding primal problem as
1
w
2
min
w,b, + ,
s.t.
C
m
(i+ + i )
(8.47a)
i=1
( w, xi + b) yi + i+ for all i
(8.47b)
yi ( w, xi + b) + i for all i
(8.47c)
i+
0, and
0.
(8.47d)
1
L(w, b, , , , , , ) = w
2
+
C
+
m
(i+
i=1
i )
(i+ i+ + i i )
i=1
i+ (( w, xi + b) yi + )
+
i=1
m
i (yi ( w, xi + b) ).
+
i=1
Taking gradients with respect to the primal variables and setting them to
0, we obtain the following conditions:
m
(i i+ )xi
w=
(8.48)
i=1
m
i+ =
i=1
(8.49)
i=1
C
m
C
i + i = .
m
i+ + i+ =
(8.50)
(8.51)
182
8 Linear Models
{+,}
{+,}
Noting that i
, i
0 and substituting the above conditions into
the Lagrangian yields the dual
1
2
min
+ ,
(i i+ )(j j+ ) xi , xj
m
(i+ + i )
+
i=1
yi (i i+ )
i=1
i+ =
s.t.
(8.52a)
i,j
i=1
(8.52b)
i=1
C
(8.52c)
m
C
0 i .
(8.52d)
m
This is a quadratic programming problem with one equality constraint, and
hence a SMO like decomposition method can be derived for finding the
optimal coefficients + and (Problem ??).
As a consequence of (8.48), analogous to the classification case, one can
map the data via a feature map into an RKHS with kernel k and recover
the decision boundary f (x) = w, (x) + b via
0 i+
(i
f (x) =
i+ )
(i i+ )k(xi , x) + b. (8.53)
(x)i , (x) + b =
i=1
i=1
C
i i = 0 and
m
i+ (( w, xi + b) yi + ) = 0 i (yi ( w, xi + b) ) = 0,
allow us to draw many useful conclusions:
Whenever |yi ( w, xi + b)| < , this implies that i+ = i = i+ =
i = 0. In other words, points which lie inside the tube around the
hyperplane w, x + b do not contribute to the solution thus leading to
sparse expansions in terms of .
C
If ( w, xi +b)yi > we have i+ > 0 and therefore i+ = m
. On the other
183
w,b, + , ,
s.t.
1
w
2
1
+
m
(i+ + i )
(8.54a)
( w, xi + b) yi + i+ for all i
(8.54b)
+C
i=1
yi ( w, xi + b) +
i+
0, i
0, and
for all i
(8.54c)
0.
(8.54d)
1
w
2
+ C +
C
m
(i+ + i )
i=1
(i+ i+ + i i )
i=1
m
i+ (( w, xi + b) yi + )
+
i=1
m
i (yi ( w, xi + b) ).
+
i=1
Taking gradients with respect to the primal variables and setting them to
0, we obtain the following conditions:
m
(i i+ )xi
w=
(8.55)
i=1
m
C =
(8.56)
(8.57)
i=1
m
i+ =
i=1
(i+ + i )
i=1
C
m
C
i + i = .
m
i+ + i+ =
(8.58)
(8.59)
184
8 Linear Models
{+,}
{+,}
Noting that i
, i
0 and substituting the above conditions into
the Lagrangian yields the dual
min
+ ,
1
2
(i
i+ )(j
yi (i i+ )
xi , xj
i,j
(8.60a)
i=1
m
i+ =
s.t.
j+ )
i=1
(8.60b)
i=1
C
m
C
0 i
m
0 i+
(8.60c)
(8.60d)
(i+ + i ) C.
(8.60e)
i=1
(8.61)
Given the input data X one can compute the empirical density
p(x) =
1
m
if x X
otherwise,
185
1
+
m
(8.62a)
i=1
w, xi i for all i
i 0.
(8.62b)
(8.62c)
Clearly, we want to be as large as possible so that the volume of the halfspace w, x is minimized. Furthermore, [0, 1] is a parameter which
is analogous to we introduced for the -SVM earlier. Roughly speaking,
it denotes the fraction of input data for which w, xi . An alternative
interpretation of (8.62) is to assume that we are separating the data set X
from the origin (See Figure BUGBUG for an illustration). Therefore, this
method is also widely known as the one-class SVM.
The Lagrangian of (8.62) can be written by introducing non-negative
Lagrange multipliers i , and i :
L(w, , , , ) =
1
w
2
1
m
i +
i=1
i ( i w, xi )
i=1
i i .
i=1
By taking gradients with respect to the primal variables and setting them
to 0 we obtain
m
w=
i xi
(8.63)
i=1
i =
1
1
i
m
m
(8.64)
i = 1.
(8.65)
i=1
Noting that i , i 0 and substituting the above conditions into the La-
186
8 Linear Models
1
2
i j xi , xj
(8.66a)
1
m
(8.66b)
i,j
s.t. 0 i
m
i = 1.
(8.66c)
i=1
p(xi |).
p(X|) =
(8.67)
i=1
p(|X)
p(xi |)p().
i=1
(8.68)
187
min
(8.69)
log p()
log min
i=1
p(xi |)
,1
(8.70)
Assuming that p() is normally distributed with zero mean and unit variance, we can further rewrite (8.70) as
1
m
2
log min
i=1
p(xi |)
,1 .
(8.71)
(8.72)
Recall that (x) denotes the sufficient statistics and g() is the log-partition
function which normalizes the distribution to sum to one. For our task,
only the shape of p(x|) matters and the normalization g() is irrelevant.
Therefore we can absorb it into by defining a new constant
and rewrite
(8.71) as
1
m
2
log min
i=1
exp ( (x), )
,1 .
(8.73)
Since
is unknown, we can introduce a variable and set
= exp(m)
for some [0, 1]. Plugging this into (8.73) and some simple algebraic
manipulations yield
J(, ) :=
m
2
max (m (x), , 0) .
(8.74)
i=1
188
8 Linear Models
8.7 Applications
8.7.1 Sequence Annotation
8.7.2 Matching
8.7.3 Ranking
8.7.4 Shortest Path Planning
8.7.5 Image Annotation
8.7.6 Contingency Table Loss
8.8 Optimization
8.8.1 Column Generation
subdifferentials
189
(8.75)
s.t.
1
w
2
m
2
+C
(8.76a)
i=1
yi w, xi 1 i for all i
(8.76b)
i 0,
(8.76c)
Derive the dual of (8.76) and contrast it with (8.11). What changes to the
SMO algorithm would you make to solve this dual?
Problem 8.2 (SMO for various SVM formulations {2}) Derive an SMO
like decomposition algorithm for solving the dual of the following problems:
-SVM (8.45).
SV regression (8.52).
SV novelty detection (8.66).
Problem 8.3 (Novelty detection with Balls {2}) In Section 8.3 we assumed that we wanted to estimate a halfspace which contains a major fraction of the input data. An alternative approach is to use balls, that is, we
estimate a ball of small radius in feature space which encloses a majority of
the input data. Write the corresponding optimization problem and its dual.
Show that if the kernel is translation invariant, that is, k(x, x ) depends only
190
8 Linear Models
9
Model Selection
9.1 Basics
Why model selection. overfitting ...
9.1.1 Estimators
unbiased estimator, bias variance dilemma
9.1.2 Maximum Likelihood Revisited
When it may overfit, when it is ok,
9.1.3 Empirical Methods
crossvalidation, show that it is unbiased
9.2 Uniform Convergence Bounds
9.2.1 Vapnik Chervonenkis Dimension
covering number arguments, chernoff bounds, just basic idea, maybe radius
margin bound
9.2.2 Rademacher Averages
explain the basic approach (from annals paper)
9.2.3 Compression Bounds
9.3 Bayesian Methods
9.3.1 Priors Revisited
9.3.2 PAC-Bayes Bounds
9.4 Asymptotic Analysis
9.4.1 Efficiency of an Estimator
Cramer Rao Bound
191
192
9 Model Selection
10
Maximum Mean Discrepancy
10.1.2 Applications
- dual of f (x) + g(x)
10.3 Priors
10.3.1 Motivation
- Philosophy and examples - Properties of priors: l1 is sparsity inducing, l2
is amenable to kernels etc
194
10.4 Moments
10.4.1 Sufficient Statistics and the Marginal Polytope
10.7 Applications
10.7.1 Independent Component Analysis
10.7.2 Feature Selection
10.7.3 Clustering
10.7.4 Maximum Variance Unfolding
10.8 Introduction
We address the problem of comparing samples from two probability distributions, by proposing statistical tests of the hypothesis that these distributions
are different (this is called the two-sample or homogeneity problem). Such
10.8 Introduction
195
196
thesizes and expands on results of [?, GBR+ 07], [SGSS07], and [SZS+ 08]1
who in turn build on the earlier work of [BGR+ 06]. Note that the latter
addresses only the third kind of test, and that the approach of [?, GBR+ 07]
employs a more accurate approximation to the asymptotic distribution of
the test statistic.
We begin our presentation in Section 10.9 with a formal definition of the
MMD, and a proof that the population MMD is zero if and only if p = q
when F is the unit ball of a universal RKHS. We also review alternative
function classes for which the MMD defines a metric on probability distributions. In Section 10.10, we give an overview of hypothesis testing as
it applies to the two-sample problem, and review other approaches to this
problem. We present our first two hypothesis tests in Section 10.11, based
on two different bounds on the deviation between the population and empirical MMD. We take a different approach in Section 10.12, where we use
the asymptotic distribution of the empirical MMD estimate as the basis for
a third test. When large volumes of data are available, the cost of computing the MMD (quadratic in the sample size) may be excessive: we therefore
propose in Section 10.13 a modified version of the MMD statistic that has
a linear cost in the number of samples, and an associated asymptotic test.
In Section 10.14, we provide an overview of methods related to the MMD in
the statistics and machine learning literature. Finally, in Section 10.15, we
demonstrate the performance of MMD-based two-sample tests on problems
from neuroscience, bioinformatics, and attribute matching using the Hungarian marriage method. Our approach performs well on high dimensional
data with low sample size; in addition, we are able to successfully distinguish
distributions on graph data, for which ours is the first proposed test.
10.9 The Maximum Mean Discrepancy
In this section, we present the maximum mean discrepancy (MMD), and
describe conditions under which it is a metric on the space of probability
distributions. The MMD is defined in terms of particular function spaces
that witness the difference in distributions: we therefore begin in Section
10.9.1 by introducing the MMD for some arbitrary function space. In Section
10.9.2, we compute both the population MMD and two empirical estimates
when the associated function space is a reproducing kernel Hilbert space,
and we derive the RKHS function that witnesses the MMD for a given pair
of distributions in Section 10.9.3. Finally, we describe the MMD for more
general function classes in Section 10.9.4.
1
197
Problem 10.1 Let p and q be Borel probability measures defined on a domain X. Given observations X := {x1 , . . . , xm } and Y := {y1 , . . . , yn },
drawn independently and identically distributed (i.i.d.) from p and q, respectively, can we decide whether p = q?
To start with, we wish to determine a criterion that, in the population
setting, takes on a unique and distinctive value only when p = q. It will be
defined based on Lemma 9.3.2 of [Dud02].
Lemma 10.1 Let (X, d) be a metric space, and let p, q be two Borel probability measures defined on X. Then p = q if and only if Exp (f (x)) =
Eyq (f (y)) for all f C(X), where C(X) is the space of bounded continuous functions on X.
Although C(X) in principle allows us to identify p = q uniquely, it is not
practical to work with such a rich function class in the finite sample setting.
We thus define a more general class of statistic, for as yet unspecified function
classes F, to measure the disparity between p and q [FM53, M
ul97].
Definition 10.2 Let F be a class of functions f : X R and let p, q, X, Y
be defined as above. We define the maximum mean discrepancy (MMD) as
MMD [F, p, q] := sup (Exp [f (x)] Eyq [f (y)]) .
(10.1)
f F
[M
ul97] calls this an integral probability metric. A biased empirical estimate
of the MMD is
MMDb [F, X, Y ] := sup
f F
1
m
f (xi )
i=1
1
n
f (yi ) .
(10.2)
i=1
The empirical MMD defined above has an upward bias (we will define an
unbiased statistic in the following section). We must now identify a function
class that is rich enough to uniquely identify whether p = q, yet restrictive
enough to provide useful finite sample estimates (the latter property will be
established in subsequent sections).
198
and consequently
|Ep [f ] Eq [f ]| > Ep f Eq f 2 >
Finally, using f
D
2
2D
8 =
D
4
> 0.
< , we have
[Ep [f ] Eq [f ]] / f
D/(4 f
H)
> 0,
199
H 1
(10.3)
Proof
2
2
MMD [F, p, q] =
H 1
H 1
H]
Eq [ (y), f
H ])
p q , f
sup
f
H 1
= p q
2
H
1
]=
(m)(m 1)
h(zi , zj ),
(10.5)
i=j
p q
2
H
p , p
+ q , q
= Ep (x), (x )
1
2 p , q
+ Eq (y), (y )
H
A sufficient condition for this is p 2H < , which is rearranged as Ep [k(x, x )] < , where
x and x are independent random variables drawn according to p. In other words, k is a trace
class operator with respect to the measure p.
200
Fig. 10.1. Illustration of the function maximizing the mean discrepancy in the case
where a Gaussian is being compared with a Laplace distribution. Both distributions
have zero mean and unit variance. The function f that witnesses the MMD has been
scaled for plotting purposes, and was computed empirically on the basis of 2 104
samples, using a Gaussian kernel with = 0.5.
1
MMDb [F, X, Y ] = 2
m
m
i,j=1
2
k(xi , xj )
mn
m,n
i,j=1
1
k(xi , yj ) + 2
n
1
2
k(yi , yj ) .
i,j=1
(10.6)
Intuitively we expect the empirical test statistic MMD[F, X, Y ], whether
biased or unbiased, to be small if p = q, and large if the distributions are
far apart. It costs O((m + n)2 ) time to compute both statistics.
Finally, we note that [HBM08] recently proposed a modification of the
kernel MMD statistic in Lemma 10.4, by scaling the feature space mean distance using the inverse within-sample covariance operator, thus employing
the kernel Fisher discriminant as a statistic for testing homogeneity. This
statistic is shown to be related to the 2 divergence.
= Ex p [k(x, x )] Ex q [k(x, x )]
m
n
1
1
= m
i=1 k(xi , x) n
i=1 k(yi , x).
201
This follows from the fact that the unit vector v maximizing v, x H in a
Hilbert space is v = x/ x .
We illustrate the behavior of MMD in Figure 10.1 using a one-dimensional
example. The data X and Y were generated from distributions p and q with
equal means and variances, with p Gaussian and q Laplacian. We chose F
to be the unit ball in an RKHS using the Gaussian kernel. We observe that
the function f that witnesses the MMD in other words, the function
maximizing the mean discrepancy in (10.1) is smooth, positive where the
Laplace density exceeds the Gaussian density (at the center and tails), and
negative where the Gaussian density is larger. Moreover, the magnitude of f
is a direct reflection of the amount by which one density exceeds the other,
insofar as the smoothness constraint permits it.
gF
f F
sup |Ep f Er f | .
f F
1
According to [Dud02, p. 26] a metric d(x, y) satisfies the following four properties: symmetry,
triangle inequality, d(x, x) = 0, and d(x, y) = 0 = x = y. A pseudo-metric only satisfies the
first three properties.
202
The first part of the theorem establishes that MMD[F, p, q] is a metric, since
only for p = q do we have MMD[F, p, q] = 0.
Note that any uniform convergence statements in terms of F allow us immediately to characterize an estimator of MMD(F, p, q) explicitly. The following result shows how (we will refine this reasoning for the RKHS case in
Section 10.11).
Theorem 10.8 Let (0, 1) be a confidence level and assume that for
some (, m, F) the following holds for samples {x1 , . . . , xm } drawn from p:
Pr sup Ep [f ]
f F
1
m
f (xi ) > (, m, F)
(10.7)
i=1
(10.8)
Proof The proof works simply by using convexity and suprema as follows:
|MMD[F, p, q] MMDb [F, X, Y ]|
1
= sup |Ep [f ] Eq [f ]| sup
f F
f F m
sup Ep [f ] Eq [f ]
f F
sup Ep [f ]
f F
1
m
1
m
m
i=1
1
f (xi )
n
f (xi ) +
i=1
1
n
f (yi )
i=1
f (xi ) + sup Eq [f ]
i=1
f (yi )
i=1
m
f F
1
n
f (yi ) .
i=1
Bounding each of the two terms via a uniform convergence bound proves
the claim.
This shows that MMDb [F, X, Y ] can be used to estimate MMD[F, p, q] and
that the quantity is asymptotically unbiased.
Remark 10.9 (Reduction to Binary Classification) Any classifier which
maps a set of observations {zi , li } with zi X on some domain X and labels
li {1}, for which uniform convergence bounds exist on the convergence
of the empirical loss to the expected loss, can be used to obtain a similarity
measure on distributions simply assign li = 1 if zi X and li = 1 for
zi Y and find a classifier which is able to separate the two sets. In this
case maximization of Ep [f ] Eq [f ] is achieved by ensuring that as many
z p(z) as possible correspond to f (z) = 1, whereas for as many z q(z)
203
1
|X|
1zxi .
i=1
m,n
mn
m+n
1
2
FX FY
>x
(1)j1 e2j
=2
2 x2
for x 0.
j=1
(10.9)
This allows for an efficient characterization of the distribution under the
null hypothesis H0 . Efficient numerical approximations to (10.9) can be
found in numerical analysis handbooks [PTVF94]. The distribution under
the alternative, p = q, however, is unknown.
The Kolmogorov metric is, in fact, a special instance of MMD[F, p, q] for
a certain Banach space [M
ul97, Theorem 5.2]
204
Proposition 10.10 Let F be the class of functions X R of bounded variation1 1. Then MMD[F, p, q] = Fp Fq .
10.9.5.2 Earth-Mover Distances
Another class of distance measures on distributions that may be written as
an MMD are the Earth-Mover distances. We assume (X, d) is a separable
metric space, and define P1 (X) to be the space of probability measures on
X for which d(x, z)dp(z) < for all p P1 (X) and x X (these are the
probability measures for which E |x| < when X = R). We then have the
following definition [Dud02, p. 420].
Definition 10.11 (Monge-Wasserstein metric) Let p P1 (X) and q
P1 (X). The Monge-Wasserstein distance is defined as
W (p, q) :=
inf
M (p,q)
= sup
f
f d(p q) ,
L 1
where
f
|f (x) f (y)|
d(x, y)
x=y X
:= sup
205
|(Fp Fq )| (x)dx,
|(Fp Fq )| (x)dx.
One may further generalize Theorem 10.12 to the set of all laws P(X) on
arbitrary metric spaces X [Dud02, Proposition 11.3.2].
Definition 10.13 (Bounded Lipschitz metric) Let p and q be laws on
a metric space X. Then
(p, q) :=
f d(p q)
sup
f
BL 1
BL
:= f
+ f
206
207
208
2 exp
See Appendix 10.17.2 for proof. Our next goal is to refine this result in
a way that allows us to define a test threshold under the null hypothesis
p = q. Under this circumstance, the constants in the exponent are slightly
improved.
2 mn
2K(m+n)
209
MMDb [F, X, Y ] m 2
B1 (F,p)
2
210
t2 m2
8K 2
where m2 := m/2 (the same bound applies for deviations of t and below).
A consistent statistical test for p = q using MMD2u is then obtained.
Corollary 10.18 A hypothesis test of level for the null hypothesis p = q
211
Second, in computing bounds rather than trying to characterize the distribution of MMD(F, X, Y ) explicitly, we force our test to be conservative by
design. In the following we aim for an exact characterization of the asymptotic distribution of MMD(F, X, Y ) instead of a bound. While this will not
satisfy the uniform convergence requirements, it leads to superior tests in
practice.
1/ m [Ser80, Theorem B, p. 193]. Under H0 , the U-statistic is degenerate, meaning Ez h(z, z ) = 0. In this case, MMD2u converges in distribution
according to
mMMD2u
l zl2 2 ,
(10.10)
l=1
x )i (x)dp(x) = i i (x ),
k(x,
212
Fig. 10.2. Left: Empirical distribution of the MMD under H0 , with p and q both
Gaussians with unit standard deviation, using 50 samples from each. Right: Empirical distribution of the MMD under H1 , with p a Laplace distribution
with unit
standard deviation, and q a Laplace distribution with standard deviation 3 2, using
100 samples from each. In both cases, the histograms were obtained by computing
2000 independent instances of the MMD.
under H1 ). One way to estimate this quantile is using the bootstrap on the
aggregated data, following [AG92]. Alternatively, we may approximate the
null distribution by fitting Pearson curves to its first four moments [JKB94,
Section 18.8]. Taking advantage of the degeneracy of the U-statistic, we
obtain (see Appendix 10.18.2)
E
MMD2u
MMD2u
2
Ez,z h2 (z, z ) and
m(m 1)
8(m 2)
Ez,z h(z, z )Ez h(z, z )h(z , z )
= 2
m (m 1)2
(10.11)
+ O(m4 ).
(10.12)
MMD2u
O(m4 ),
small,
and expensive to calculate, O(m4 ). Instead, we replace the
kurtosis1 with a lower bound due to [Wil44], kurt MMD2u skew MMD2u
1.
Note that MMD2u may be negative, since it is an unbiased estimator of
(MMD[F, p, q])2 . However, the only terms missing to ensure nonnegativity
are the terms h(zi , zi ), which were removed to remove spurious correlations
between observations. Consequently we have the bound
MMD2u +
1
m(m 1)
(10.13)
i=1
The kurtosis is defined in terms of the fourth and second moments as kurt MMD2u =
4
E [MMD2
u]
h
i2 3.
2
2
E [MMDu ]
213
1
] :=
m2
m2
t2 m2
8K 2
where m2 := m/2 (the same bound applies for deviations of t and below).
Note that the bound of Theorem 10.17 is identical to that of Theorem 10.21,
which shows the former is rather loose. Next we invoke the central limit
theorem.
Corollary 10.22 Assume 0 < E h2 < . Then MMD2l converges in distribution to a Gaussian according to
1
, uniformly at rate 1/ m.
The factor of 2 arises since we are averaging over only m/2 observations. Note the difference in the variance between Theorem 10.19 and Corollary 10.22, namely in the former case we are interested in the average conditional variance Ez Varz [h(z, z )|z], whereas in the latter case we compute
the full variance Varz,z [h(z, z )].
214
We end by noting another potential approach to reducing the computational cost of the MMD, by computing a low rank approximation to the
Gram matrix [FS01, WS01, SS00]. An incremental computation of the MMD
based on such a low rank approximation would require O(md) storage and
O(md) computation (where d is the rank of the approximate Gram matrix which is used to factorize both matrices) rather than O(m) storage and
O(m2 ) operations. That said, it remains to be determined what effect this
approximation would have on the distribution of the test statistic under H0 ,
and hence on the test threshold.
hdm
lim hdm = 0
x
hm
and
(10.14)
We now show that the L2 distance between Parzen windows density estimates [AHT94] is a special case of the biased MMD in equation (10.6).
Denote by Dr (p, q) := p q r the Lr distance. For r = 1 the distance
Dr (p, q) is known as the Levy distance [Fel71], and for r = 2 we encounter
distance measures derived from the Renyi entropy [GP02].
215
Assume that p and q are given as kernel density estimates with kernel
(x x ), that is, p(x) = m1 i (xi x) and q(y) is defined by analogy.
In this case
1
m
D2 (
p, q) =
=
1
m2
1
(xi z)
n
k(xi xj ) +
i,j=1
1
n2
(yi z)
dz
i
n
k(yi yj )
i,j=1
2
mn
(10.15)
m,n
k(xi yj ),
i,j=1
(10.16)
where k(x y) = (x z)(y z)dz. By its definition k(x y) is a Mercer
kernel [Mer09], as it can be viewed as inner product between (x z) and
(y z) on the domain X.
A disadvantage of the Parzen window interpretation is that when the
Parzen window estimates are consistent (which requires the kernel size to
decrease with increasing sample size), the resulting two-sample test converges more slowly than using fixed kernels. According to [AHT94, p. 43],
d/2
the Type II error of the two-sample test converges as m1/2 hm . Thus,
given the schedule for the Parzen window size decrease in (10.14), the convergence rate will lie in the open interval (0, 1/2): the upper limit is approached as hm decreases more slowly, and the lower limit corresponds to
hm decreasing near the upper bound of 1/m. In other words, by avoiding
density estimation, we obtain a better convergence rate (namely m1/2 ) than
using a Parzen window estimate with any permissible bandwidth decrease
schedule. In addition, the Parzen window interpretation cannot explain the
excellent performance of MMD based tests in experimental settings where
the dimensionality greatly exceeds the sample size (for instance the Gaussian toy example in Figure 10.4B, for which performance actually improves
when the dimensionality increases; and the microarray datasets in Table
10.1). Finally, our tests are able to employ universal kernels that cannot be
written as inner products between Parzen windows, normalized or otherwise:
several examples are given by [Ste01, Section 3] and [MXZ06, Section 3]. We
may further generalize to kernels on structured objects such as strings and
graphs [STV04]: see also our experiments in Section 10.15.
10.14.2 Set Kernels and Kernels Between Probability Measures
[?] propose kernels to deal with sets of observations. These are then used
in the context of Multi-Instance Classification (MIC). The problem MIC
attempts to solve is to find estimators which are able to infer from the
216
fact that some elements in the set satisfy a certain property, then the set
of observations has this property, too. For instance, a dish of mushrooms
is poisonous if it contains poisonous mushrooms. Likewise a keyring will
open a door if it contains a suitable key. One is only given the ensemble,
however, rather than information about which instance of the set satisfies
the property.
The solution proposed by [?] is to map the ensembles Xi := {xi1 , . . . , ximi },
where i is the ensemble index and mi the number of elements in the ith ensemble, jointly into feature space via
1
(Xi ) :=
mi
mi
(xij ),
(10.17)
j=1
and use the latter as the basis for a kernel method. This simple approach
affords rather good performance. With the benefit of hindsight, it is now
understandable why the kernel
k(Xi , Xj ) =
1
mi mj
mi ,mj
k(xiu , xjv )
(10.18)
u,v
produces useful results: it is simply the kernel between the empirical means
in feature space (Xi ), (Xj ) [HLB04, Eq. 4]. [JK03] later extended this
setting by smoothing the empirical densities before computing inner products.
Note, however, that property testing for distributions is probably not optimal when using the mean [p] (or [X] respectively): we are only interested in determining whether some instances in the domain have the desired
property, rather than making a statement regarding the distribution of those
instances. Taking this into account leads to an improved algorithm [ATH03].
217
GBSS05, GHS+ 05]. In the following we re-derive one of the above kernel
independence measures using mean operators instead.
We begin by defining
[Pr] := Ex,y [v((x, y), )]
xy
Here we assumed that V is an RKHS over XY with kernel v((x, y), (x , y )).
If x and y are dependent, the equality [Prxy ] = [Prx Pry ] will not hold.
Hence we may use := [Prxy ] [Prx Pry ] as a measure of dependence.
Now assume that v((x, y), (x , y )) = k(x, x )l(y, y ), i.e. that the RKHS V
is a direct product H G of the RKHSs on X and Y. In this case it is easy
to see that
2 =
218
Fig. 10.3. Illustration of the function maximizing the mean discrepancy when MMD
is used as a measure of independence. A sample from dependent random variables
x and y is shown in black, and the associated function f that witnesses the MMD
is plotted as a contour. The latter was computed empirically on the basis of 200
samples, using a Gaussian kernel with = 0.2.
(10.19)
That is, we compute the average distance between p and q with respect to
a distribution of test functions.
Lemma 10.25 Let H be a reproducing kernel Hilbert space, f H, and assume r(f ) = r( f H ) with finite Ef r [ f H ]. Then D(p, q) = C [p] [q] H
for some constant C which depends only on H and r.
Proof By definition Ep [f (x)] = [p], f
product, Equation (10.19) equals
| [p] [q], f
= [p] [q]
H.
H | dr(f )
[p] [q]
,f
[p] [q] H
dr(f ),
H
where the integral is independent of p, q. To see this, note that for any p, q,
[p][q]
[p][q] H is a unit vector which can turned into, say, the first canonical
basis vector by a rotation which leaves the integral invariant, bearing in
10.15 Experiments
219
10.15 Experiments
We conducted distribution comparisons using our MMD-based tests on datasets
from three real-world domains: database applications, bioinformatics, and
neurobiology. We investigated both uniform convergence approaches (MMDb
with the Corollary 10.16 threshold, and MMD2u H with the Corollary 10.18
threshold); the asymptotic approaches with bootstrap (MMD2u B) and moment matching to Pearson curves (MMD2u M), both described in Section
10.12; and the asymptotic approach using the linear time statistic (MMD2l )
from Section 10.13. We also compared against several alternatives from
the literature (where applicable): the multivariate t-test, the FriedmanRafsky Kolmogorov-Smirnov generalisation (Smir), the Friedman-Rafsky
Wald-Wolfowitz generalisation (Wolf ), the Biau-Gyorfi test (Biau), and the
Hall-Tajvidi test (Hall). See Section 10.10.3 for details regarding these tests.
Note that we do not apply the Biau-Gyorfi test to high-dimensional prob-
220
lems (since the required space partitioning is no longer possible), and that
MMD is the only method applicable to structured data such as graphs.
An important issue in the practical application of the MMD-based tests
is the selection of the kernel parameters. We illustrate this with a Gaussian
RBF kernel, where we must choose the kernel width (we use this kernel for
univariate and multivariate data, but not for graphs). The empirical MMD
is zero both for kernel size = 0 (where the aggregate Gram matrix over
X and Y is a unit matrix), and also approaches zero as (where
the aggregate Gram matrix becomes uniformly constant). We set to be
the median distance between points in the aggregate sample, as a compromise between these two extremes: this remains a heuristic, similar to those
described in [TLSS06, Sch97], and the optimum choice of kernel size is an
ongoing area of research.
10.15 Experiments
221
Fig. 10.4. Type II performance of the various tests when separating two Gaussians,
with test level = 0.05. A Gaussians have same variance and different means. B
Gaussians have same mean and different variances.
222
Dataset
Attr.
MMDb
MMD2u H
MMD2u B
MMD2u M
t-test
Wolf
Smir
Hall
Neural Data I
Same
100.0
100.0
96.5
96.5
100.0
97.0
95.0
96.0
38.0
100.0
0.0
0.0
42.0
0.0
10.0
49.0
100.0
100.0
94.6
95.2
100.0
95.0
94.5
96.0
99.7
100.0
3.3
3.4
100.0
0.8
31.8
5.9
Same
100.0
100.0
95.5
94.4
100.0
94.7
96.1
95.6
Different
100.0
100.0
1.0
0.8
100.0
2.8
44.0
35.7
Same
100.0
100.0
99.1
96.4
100.0
94.6
97.3
96.5
Different
100.0
100.0
0.0
0.0
100.0
0.0
28.4
0.2
Different
Neural Data II
Same
Different
Health status
Subtype
10.15 Experiments
223
224
available, a better option is to look at each point only once, which can yield
greater accuracy for a given computational cost. It may also be worth doing a
t-test first in this case, and only running more sophisticated non-parametric
tests if the t-test accepts the null hypothesis, to verify the distributions are
identical in more than just mean.
Note that corresponding attributes may have different distributions in real-world databases.
Hence, schema matching cannot solely rely on distribution testing. Advanced approaches to
schema matching using MMD as one key statistical test are a topic of current research.
10.15 Experiments
225
Fig. 10.5. Linear vs quadratic MMD. First column is performance, second is runtime. The dashed grey horizontal line indicates zero Type II error (required due log
y-axis)
226
are Smir, Biau, or the t-test. Thus, MMD2u appears to perform more consistently across the multiple datasets. The Friedman-Rafsky tests do not
always return a Type I error close to the design parameter: for instance,
Wolf has a Type I error of 9.7% on the BIO dataset (on these data, MMD2u
has the joint best Type II error without compromising the designed Type
I performance). Finally, MMDb performs much better than in Table 10.1,
although surprisingly it fails to reliably detect differences in FOREST10D.
The results of MMD2u H are also improved, although it remains among the
worst performing methods.
A more principled approach to attribute matching is also possible. Assume that (A) = (1 (A1 ), 2 (A2 ), ..., n (An )): in other words, the kernel
decomposes into kernels on the individual attributes of A (and also decomposes this way on the attributes of B). In this case, M M D2 can be written
n
2
i=1 i (Ai ) i (Bi ) , where we sum over the MMD terms on each of
the attributes. Our goal of optimally assigning attributes from B to attributes of A via MMD is equivalent to finding the optimal permutation
of attributes of B that minimizes ni=1 i (Ai ) i (B(i) ) 2 . If we define
Cij = i (Ai ) i (Bj ) 2 , then this is the same as minimizing the sum over
Ci,(i) . This is the linear assignment problem, which costs O(n3 ) time using
the Hungarian method [Kuh55].
While this may appear to be a crude heuristic, it nonetheless defines a
semi-metric on the sample spaces X and Y and the corresponding distributions p and q. This follows from the fact that matching distances are
proper metrics if the matching cost functions are metrics. We formalize this
as follows:
[F, p, q] := min
MMD[F, pi , q(i) ]
i=1
Proof Clearly [F, p, q] is nonnegative, since all of its summands are. Next
we show the triangle inequality. Denote by r a third distribution on Rd and
let p,q , q,r and p,r be the distance minimizing permutations between p, q
10.15 Experiments
227
[F, p, q] + [F, q, r] =
Here the first inequality follows from the triangle inequality on MMD, that
is
MMD[F, pi , qp,q (i) ]+MMD[F, qp,q (i) , r[p,q q,r ](i) ] MMD[F, pi , r[p,q q,r ](i) ].
The second inequality is a result of minimization over .
Dataset
Attr.
MMDb
MMD2u H
MMD2u B
MMD2u M
t-test
Wolf
Smir
Hall
Bia
BIO
Same
100.0
100.0
93.8
94.8
95.2
90.3
95.8
95.3
99
20.0
52.6
17.2
17.6
36.2
17.2
18.6
17.9
42
100.0
100.0
96.4
96.0
97.4
94.6
99.8
95.5
100
3.9
11.0
0.0
0.0
0.2
3.8
0.0
50.1
0.
100.0
100.0
94.5
93.8
94.0
98.4
97.5
91.2
98
14.9
52.7
2.7
2.5
19.17
22.5
11.6
79.1
50
100.0
100.0
94.0
94.0
100.0
93.5
96.5
97.0
100
86.6
100.0
0.0
0.0
0.0
0.0
1.0
72.0
100
Different
FOREST
Same
Different
CNUM
Same
Different
FOREST10D
Same
Different
228
the Hungarian method (the other tests were not applicable to this graph
data). The challenge here is to match tables representing one functional
class of proteins (or enzymes) from dataset A to the corresponding tables
(functional classes) in B. Results are shown in Table 10.3. Besides on the
BIO and CNUM datasets, MMD2u B made no errors.
Dataset
Data type
No. attributes
Sample size
Repetitions
% correct matches
BIO
univariate
377
100
90.0
CNUM
univariate
13
386
100
99.8
FOREST
univariate
10
538
100
100.0
FOREST10D
multivariate
1000
100
100.0
ENZYME
structured
50
50
100.0
PROTEINS
structured
200
50
100.0
10.16 Conclusion
We have established three simple multivariate tests for comparing two distributions p and q, based on samples of size m and n from these respective
distributions. Our test statistic is the maximum mean discrepancy (MMD),
defined as the maximum deviation in the expectation of a function evaluated
on each of the random variables, taken over a sufficiently rich function class:
in our case, a universal reproducing kernel Hilbert space (RKHS). Equivalently, the statistic can be written as the norm of the difference between
distribution feature means in the RKHS. We do not require density estimates
as an intermediate step. Two of our tests provide Type I error bounds that
are exact and distribution-free for finite sample sizes. We also give a third
test based on quantiles of the asymptotic distribution of the associated test
statistic. All three tests can be computed in O((m + n)2 ) time, however
when sufficient data are available, a linear time statistic can be used, which
employs more data to get better results at smaller computational cost. In
addition, a number of metrics on distributions (Kolmogorov-Smirnov, Earth
10.16 Conclusion
229
While our result establishes that statistical tests based on the MMD are
consistent for universal kernels on compact domains, we draw attention to
the recent introduction of characteristic kernels by [FGSS08], these being
kernels for which the mean map is injective. Fukumizu et al. establish that
Gaussian and Laplace kernels are characteristic on Rd , and thus the MMD
is a consistent test for this domain. [?] further explore the properties of
characteristic kernels, providing a simple condition to determine whether
convolution kernels are characteristic, and describing characteristic kernels
which are not universal on compact domains. We also note (following Section 10.14.2) that the MMD for RKHSs is associated with a particular kernel between probability distributions. [HLB04] describe several further such
kernels, which induce corresponding distances between feature space distribution mappings: these may in turn lead to new and powerful two-sample
tests.
Two recent studies have shown that additional divergence measures between distributions can be obtained empirically through optimization in a
reproducing kernel Hilbert space. [HBM08] build on the work of [?], considering a homogeneity statistic arising from the kernel Fisher discriminant,
rather than the difference of RKHS means; and [NWJ08] obtain a KL divergence estimate by approximating the ratio of densities (or its log) with a
function in an RKHS. By design, both these kernel-based statistics prioritise
different features of p and q when measuring the divergence between them,
and the resulting effects on distinguishability of distributions are therefore
of interest.
Finally, we have seen in Section 10.9 that several classical metrics on probability distributions can be written as maximum mean discrepancies with
function classes that are not Hilbert spaces, but rather Banach, metric, or
semi-metric spaces. It would be of particular interest to establish under
what conditions one could write these discrepancies in terms of norms of
differences of mean elements. In particular, [DL07] consider Banach spaces
endowed with a semi-inner product, for which a General Riesz Representation exists for elements in the dual.
230
> 0,
m
2
i=1 ci
We also define the Rademacher average of the function class F with respect
to the m-sample X.
Definition 10.28 (Rademacher average of F on X) Let F be the unit
ball in a universal RKHS on the compact domain X, with kernel bounded
according to 0 k(x, y) K. Let X be an i.i.d. sample of size m drawn
according to a probability measure p on X, and let i be i.i.d and take values
in {1, 1} with equal probability. We define the Rademacher average
Rm (F, X) := E sup
f F
1
m
i f (xi )
i=1
(K/m)1/2 ,
where the upper bound is due to [BM02, Lemma 22]. Similarly, we define
1
Rm (F, p) := Ep, sup
m
f F
i f (xi ) .
i=1
10.17 Large Deviation Bounds for Tests with Finite Sample Guarantees
231
1
m
f F
sup Ep (f ) Eq (f )
f F
1
m
f (xi )
i=1
f (xi ) +
i=1
1
n
1
n
f (yi )
i=1
f (yi ) .
(10.20)
i=1
(p,q,X,Y )
m 2K 1/2 /m
+ n 2K 1/2 /n
= 4K
1
1
+
m n
= 4K
m+n
,
mn
to obtain
2 mn
.
2K(m + n)
(10.21)
For our final result, we exploit symmetrisation, following e.g. [vdVW96, p.
108], to upper bound the expectation of (p, q, X, Y ). Denoting by X an
i.i.d sample of size m drawn independently of X (and likewise for Y ), we
232
have
EX,Y [(p, q, X, Y )]
=
EX,Y
1
m
EX,Y sup EX
f F
EX,Y,X
,Y
1
m
sup
f F
(a)
EX,Y,X
,Y ,,
sup
f F
EX,X sup
(b)
f F
1
sup Ep (f )
m
f F
1
m
i=1
1
f (xi ) Eq (f ) +
n
f (xi )
i=1
m
f (xi )
i=1
1
m
1
m
1
m
f (yj )
i=1
1
n
f (xi ) EY
i=1
f (xi )
i=1
1
n
i f (xi ) f (xi ) +
i=1
+ EY,Y
i=1
f (yj )
f (yj ) +
i=1
n
1
n
i=1
1
n
1
n
f (yj )
i=1
f (yj )
i=1
i f (yj ) f (yj )
i=1
i f (xi ) f (xi )
sup
f F
1
n
i f (yj ) f (yj )
i=1
(c)
2 (K/m)1/2 + (K/n)1/2 ,
(10.22)
(d)
where (a) uses Jensens inequality, (b) uses the triangle inequality, (c) substitutes Definition 10.28 (the Rademacher average), and (d) bounds the
Rademacher averages, also via Definition 10.28.
Having established our preliminary results, we proceed to the proof of
Theorem 10.14.
Proof [Theorem 10.14] Combining equations (10.21) and (10.22), gives
Pr (p, q, X, Y ) 2 (K/m)1/2 + (K/n)1/2 >
exp
2 mn
2K(m + n)
233
same three steps as in the previous section. The first step in (10.20) becomes
MMDb (F, X, Y ) MMD(F, p, q) = MMDb (F, X, X ) 0
= sup
f F
1
m
f (xi ) f (xi )
.(10.23)
i=1
The McDiarmid bound on the difference between (10.23) and its expectation
is now a function of 2m observations in (10.23), and has a denominator in
2
the exponent of 2m 2K 1/2 /m = 8K/m. We use a different strategy in
obtaining an upper bound on the expected (10.23), however: this is now
EX,X
=
1
EX,X
m
1
m
f F
f (xi ) f (xi )
i=1
(xi ) (xi )
i=1
sup
1
EX,X
m
1
2
1
2mEx k(x, x) + 2m(m 1)Ex,x k(x, x ) 2m2 Ex,x k(x, x )
m
2
Ex,x k(x, x) k(x, x )
m
1
2
1
2
(10.24)
(2K/m)1/2 .
(10.25)
We remark that both (10.24) and (10.25) bound the amount by which our
biased estimate of the population MMD exceeds zero under H0 . Combining
the three results, we find that under H0 ,
pX
1
2
>
< exp
2m
4K
< exp
2m
4K
2
MMDb (F, X, X )
Ex,x k(x, x) k(x, x )
m
and
.
234
1
m(m 1)
h(zi , zj ),
(10.27)
i=j
mMMD2u [F, X, X
l 21l 1 ,
]
l=1
where 21l are independent chi squared random variables of degree one, and
l are the solutions to the eigenvalue equation
l l (u) =
While this result is adequate for our purposes (since we do not explicitly
use the quantities l in our subsequent reasoning), it does not make clear
the dependence of the null distribution on the kernel choice. For this reason,
we provide an alternative expression based on the reasoning of [AHT94,
Appendix], bearing in mind the following changes:
we do not need to deal with the bias terms S1j seen by [AHT94, Appendix]
that vanish for large sample sizes, since our statistic is unbiased (although
these bias terms drop faster than the variance);
we require greater generality, since we deal with distributions on compact
metric spaces, and not densities on Rd ; correspondingly, our kernels are
235
The centering terms cancel (the distance between the two points is unaffected by an identical global shift in both the points), meaning
i , xj ) + k(y
i , yj ) k(x
i , yj ) k(x
j , yi ).
h(zi , zj ) = k(x
i , xj ) in terms of eigenfunctions i (x) with
Next, we write the kernel k(x
respect to the probability measure Prx ,
x)=
k(x,
l l (x)l (x ),
l=1
where
X
x )i (x)d Pr(x) = i i (x )
k(x,
x
and
X
(10.28)
Since
v) = Ex k(x, v) Ex,x k(x, x ) Ex k(x, v) + Ex,x k(x, x )
Ex k(x,
= 0,
then when i = 0, we have that
i Ex i (x ) =
x )i (x)d Pr(x)
Ex k(x,
x
= 0,
and hence
Ex i (x) = 0.
(10.29)
236
i , xj )
k(x
i=j
1
m
1
m
l l (xi )l (xj )
i=j l=1
l
i
l=1
l2 (xi )
l (xi )
l (yl2 1),
l=1
where yl N(0, 1) are i.i.d., and the final relation denotes convergence
in distribution, using (10.28) and (10.29), following [Ser80, Section 5.5.2].
Likewise
1
m
,x )
k(x
i j
D
i=j
l (zl2 1),
l=1
i , yj ) + k(x
j , yi )
k(x
i=j
2
D
l yl zl .
l=1
mMMD2u (F, X, X )
D
l=1
l (yl zl )2 2 .
=
l=1
(10.30)
Ez h(z, z ) = 0.
(10.31)
and, importantly,
237
MMD2u
2
2
n(n 1)
n(n 1)
(n 2)(2)Ez (Ez h(z, z ))2 +
Ez,z h2 (z, z )
n(n 1)
2
2
2
2(n 2)
=
Ez (Ez h(z, z ))2 +
Ez,z h2 (z, z )
n(n 1)
n(n 1)
2
=
Ez,z h2 (z, z ) ,
n(n 1)
where the first term in the penultimate line is zero due to (10.31). Note that
variance and 2nd moment are the same under the zero mean assumption.
3rd moment: We consider the terms that appear in the expansion of
3
E MMD2u . These are all of the form
3
2
n(n 1)
where we shorten hab = h(za , zb ), and we know za and zb are always independent. Most of the terms vanish due to (10.30) and (10.31). The first
terms that remain take the form
3
2
n(n 1)
2
n(n 1)
Ez,z h3 (z, z ) ,
238
n(n1)
2
Ez,z h3 (z, z ) .
(10.33)
2
However n(n1)
n4 so this term is negligible compared with (10.32).
Thus, a reasonable approximation to the third moment is
MMD2u
8(n 2)
Ez,z h(z, z )Ez
n2 (n 1)2
h(z, z )h(z , z )
11
Reinforcement Learning
239
Appendix 1
Linear Algebra and Functional Analysis
241
Appendix 2
Conjugate Distributions
242
Conjugate Distributions
243
Binomial Beta
(x) = x
(n + 1)(n(1 ) + 1)
eh(n,n) =
= B(n + 1, n(1 ) + 1)
(n + 2)
In traditional notation one represents the conjugate as
p(z; , ) =
( + ) 1
z
(1 z)1
()()
d
i=1 (ni
+ 1)
(n + d)
d
d
i=1 i )
zii 1
d
i=1 (i ) i=1
where i = ni + 1
Poisson Gamma
(x) = x
h(n,n)
= nn (n)
Multinomial / Binomial
Gaussian
Laplace
Poisson
Dirichlet
Wishart
Student-t
Beta
Gamma
Appendix 3
Loss Functions
244
(3.1)
0 if f and 1 otherwise
f y
sign(f y)
if f > y and 1 otherwise
0 if |f y| , else sign(f y)
f y if |f y| 1, else sign(f y)
exp(yf )
log(1 + exp(yf ))
max(0, f )
1
2 (f
|f y|
max( (f y), (1 )(y f ))
max(0, |f y| )
1
2 (f
exp(f ) yf
Exponential [CDLS99]
Logistic [CSS00]
-insensitive [VGS97]
exp(f ) y
y/(1 + exp(yf ))
1
2 (f
Multivariate Regression
exp(fy ) fy
y) M (f y) where M
ey exp(fy ) /
M (f y)
exp(fy ) ey
(y, y )(ey ey )
where y is the argmax of the loss
ey ey
where y is the argmax of the loss
Derivative
Loss
Vectorial loss functions and their derivatives, depending on the vector f := W x and on y.
y)2 if |f y| 1, else |f y|
y)2
1
2
0 if yf 1 and f y otherwise
1
2
0 if yf 1 and y otherwise
max(0, 1 yf )
Hinge [BM92]
max(0, 1 yf )2
Derivative l (f, y)
Loss l(f, y)
246
3 Loss Functions
x f (x)
if f (x) g(x)
x g(x)
otherwise .
(3.2)
Since we are only interested in obtaining an arbitrary element of the subdifferential this convention is consistent with our requirements.
Let us discuss the issue of efficient computation. For all scalar losses we
may write l(x, y, w) = l( w, x , y), as described in Table A3.1. In this case a
simple application of the chain rule yields that w l(x, y, w) = l ( w, x , y)x.
For instance, for squared loss we have
l( w, x , y) = 1 ( w, x y)2 and l ( w, x , y) = w, x y.
2
Consequently, the derivative of the empirical risk term is given by
w Remp (w) =
1
m
l ( w, xi , yi ) xi .
(3.3)
i=1
(3.4)
This is possible for any of the loss functions listed in Table A3.1, and many
other similar losses. The advantage of this unified representation is that implementation of each individual loss can be done in very little time. The
computational infrastructure for computing Xw and g X is shared. Evaluating l(fi , yi ) and l (fi , yi ) for all i can be done in O(m) time and it is
not time-critical in comparison to the remaining operations. Algorithm 3.1
describes the details.
An important but often neglected issue is worth mentioning. Computing f
requires us to right multiply the matrix X with the vector w while computing
g requires the left multiplication of X with the vector g . If X is stored in a
row major format then Xw can be computed rather efficiently while g X is
247
3: Compute r =
i l(fi , yi ) and g = l (f, y)
4: g g X
5: return Risk r and gradient g
(3.5)
(3.6)
l(x, y, w) = log
exp
w, (x, y )
y Y
Here (x, y) is a joint feature map, (y, y ) 0 describes the cost of misclassifying y by y , and (y, y ) 0 is a scaling term which indicates by how
much the large margin property should be enforced. For instance, [TGK04]
choose (y, y ) = 1. On the other hand [TJHA05] suggest (y, y ) = (y, y ),
which reportedly yields better performance. Finally, [McA07] recently suggested generic functions (y, y ).
The logistic loss can also be interpreted as the negative log-likelihood of
a conditional exponential family model:
p(y|x; w) := exp( w, (x, y) g(w|x)),
(3.7)
where the normalizing constant g(w|x), often called the log-partition function, reads
g(w|x) := log
exp
y Y
w, (x, y )
(3.8)
248
3 Loss Functions
As a consequence of the Hammersley-Clifford theorem [Jor08] every exponential family distribution corresponds to a undirected graphical model. In
our case this implies that the labels y factorize according to an undirected
graphical model. A large number of problems have been addressed by this
setting, amongst them named entity tagging [LMP01], sequence alignment
[TJHA05], segmentation [RSS+ 07] and path planning [RBZ06]. It is clearly
impossible to give examples of all settings in this section, nor would a brief
summary do this field any justice. We therefore refer the reader to the edited
volume [BHS+ 07] and the references therein.
If the underlying graphical model is tractable then efficient inference algorithms based on dynamic programming can be used to compute (3.5) and
(3.6). We discuss intractable graphical models in Section A3.1.2.1, and now
turn our attention to the derivatives of the above structured losses.
When it comes to computing derivatives of the logistic loss, (3.5), we have
w l(x, y, w) =
exp w, (x, y )
(x, y)
(3.9)
(3.10)
where p(y|x) is the exponential family model (3.7). In the case of (3.6) we
denote by y(x) the argmax of the RHS, that is
y(x) := argmax (y, y ) w, (x, y ) (x, y) + (y, y ).
(3.11)
(3.12)
In the case where the loss is maximized for more than one distinct value y(x)
we may average over the individual values, since any convex combination of
such terms lies in the subdifferential.
Note that (3.6) majorizes (y, y ), where y := argmaxy w, (x, y )
[TJHA05]. This can be seen via the following series of inequalities:
(y, y ) (y, y ) w, (x, y ) (x, y) + (y, y ) l(x, y, w).
The first inequality follows because (y, y ) 0 and y maximizes w, (x, y )
thus implying that (y, y ) w, (x, y ) (x, y) 0. The second inequality follows by definition of the loss.
We conclude this section with a simple lemma which is at the heart of
several derivations of [Joa05]. While the proof in the original paper is far
from trivial, it is straightforward in our setting:
249
Lemma 3.1 Denote by (y, y ) a loss and let (xi , yi ) be a feature map for
observations (xi , yi ) with 1 i m. Moreover, denote by X, Y the set of
all m patterns and labels respectively. Finally let
m
(X, Y ) :=
(yi , yi ).
(3.13)
i=1
This is immediately obvious, since both feature map and loss decompose,
which allows us to perform maximization over Y by maximizing each of its
m components. In doing so, we showed that aggregating all data and labels
into a single feature map and loss yields results identical to minimizing
the sum over all individual losses. This holds, in particular, for the sample
error loss of [Joa05]. Also note that this equivalence does not hold whenever
(y, y ) is not constant.
A3.1.2.1 Intractable Models
We now discuss cases where computing l(x, y, w) itself is too expensive. For
instance, for intractable graphical models, the computation of y exp w, (x, y)
cannot be computed efficiently. [WJ03] propose the use of a convex majorization of the log-partition function in those cases. In our setting this means
that instead of dealing with
l(x, y, w) = g(w|x) w, (x, y) where g(w|x) := log
exp w, (x, y)
y
(3.14)
one uses a more easily computable convex upper bound on g via
sup
w, + HGauss (|x).
(3.15)
MARG(x)
250
3 Loss Functions
Likewise note that [TGK04] use relaxations when solving structured estimation problems of the form
l(x, y, w) = max (y, y ) w, (x, y ) (x, y) + (y, y ),
y
(3.16)
1
m+ m
I( w, xi < w, xj ),
(3.17)
yi <yj
1
m+ m
max(0, 1 + w, xi xj ) =
yi <yj
1
m+ m
max(0, 1 + fi fj ).
yi <yj
(3.18)
Obviously, we could compute Remp (w) and its derivative by an O(m2 ) operation. However [Joa05] showed that both can be computed in O(m log m)
time using a sorting operation, which we now describe.
Denote by c = f 21 y an auxiliary variable and let i and j be indices such
251
252
3 Loss Functions
yi <yj
1
m2
C(yi , yj )I( w, xi > w, xj ) where M =
2
m2i . (3.19)
i
Using the same convex majorization as above when we were maximizing the
ROC score, we obtain an empirical risk of the form
Remp (w) =
1
M
C(yi , yj ) max(0, 1 + w, xi xj )
(3.20)
yi <yj
Now the goal is to find an efficient algorithm for obtaining the number of
times when the individual losses are nonzero such as to compute both the
value and the gradient of Remp (w). The complication arises from the fact
that observations xi with label yi may appear in either side of the inequality
depending on whether yj < yi or yj > yi . This problem can be solved as
follows: sort f = Xw in ascending order and traverse it while keeping track
of how many items with a lower value yj are no more than 1 apart in terms
of their value of fi . This way we may compute the count statistics efficiently.
Algorithm 3.3 describes the details, generalizing the results of [Joa06]. Again,
its runtime is O(m log m), thus allowing for efficient computation.
(3.21)
253
1
|P |
1
|P |
C(i, j)
(i,j)P
if w, xj xi 1
xi xj
otherwise
(3.23)
254
3 Loss Functions
A3.1.3.4 Ranking
In webpage and document ranking we are often in a situation similar to that
described in Section A3.1.3.2, however with the difference that we do not
only care about objects xi being ranked according to scores yi but moreover
that different degrees of importance are placed on different documents.
The information retrieval literature is full with a large number of different scoring functions. Examples are criteria such as Normalized Discounted
Cumulative Gain (NDCG), Mean Reciprocal Rank (MRR), Precision@n, or
Expected Rank Utility (ERU). They are used to address the issue of evaluating rankers, search engines or recommender sytems [Voo01, JK02, BHK98,
BH04]. For instance, in webpage ranking only the first k retrieved documents that matter, since users are unlikely to look beyond the first k, say
10, retrieved webpages in an internet search. [LS07] show that these scores
can be optimized directly by minimizing the following loss:
ci w, x(i) xi + a a(), b(y) .
l(X, y, w) = max
(3.24)
(3.25)
255
(3.26)
Here 1 denotes the inverse permutation, such that 1 = 1. Finding the
permutation maximizing c f () a() b(y) is a linear assignment problem
which can be easily solved by the Hungarian Marriage algorithm, that is,
the Kuhn-Munkres algorithm.
The original papers by [Kuh55] and [Mun57] implied an algorithm with
O(m3 ) cost in the number of terms. Later, [Kar80] suggested an algorithm
with expected quadratic time in the size of the assignment problem (ignoring log-factors). Finally, [OL93] propose a linear time algorithm for large
problems. Since in our case the number of pages is fairly small (in the order
of 50 to 200 per query) the scaling behavior per query is not too important.
We used an existing implementation due to [JV87].
Note also that training sets consist of a collection of ranking problems,
that is, we have several ranking problems of size 50 to 200. By means of
parallelization we are able to distribute the work onto a cluster of workstations, which is able to overcome the issue of the rather costly computation
per collection of queries. Algorithm 3.5 spells out the steps in detail.
A3.1.3.5 Contingency Table Scores
[Joa05] observed that F scores and related quantities dependent on a contingency table can also be computed efficiently by means of structured estimation. Such scores depend in general on the number of true and false
positives and negatives alike. Algorithm 3.6 shows how a corresponding empirical risk and subgradient can be computed efficiently. As with the previous losses, here again we use convex majorization to obtain a tractable
optimization problem.
256
3 Loss Functions
y<0
y >0
T+
F+
y <0
(1 + 2 )T+
.
T+ + m T + 2 m+
(3.27)
(3.28)
257
f , i = 1, . . . , m
Let n0 = 0 and ni = 2 k=i
k
y y and r
for i = 0 to m+ do
for j = 0 to m do
rtmp = (i, j) pi + nj
if rtmp > r then
r rtmp
T+ i and T j
end if
end for
end for
y+ 1, i = 1, . . . , T+
i
18:
y 1, i = 1, . . . , T
19:
g (y y) X
return Risk r and subgradient g
20:
(3.29)
(3.30)
Here and are defined as in Section A3.1.2 and y denotes the value of y
258
3 Loss Functions
for which the RHS of (3.29) is maximized. This means that for unstructured
multiclass settings we may simply compute xW . Since this needs to be performed for all observations xi we may take advantage of fast linear algebra
routines and compute f = XW for efficiency. Likewise note that computing the gradient over m observations is now a matrix-matrix multiplication,
too: denote by G the matrix of rows of gradients (yi , yi )(eyi eyi ). Then
W Remp (X, y, W ) = G X. Note that G is very sparse with at most two
nonzero entries per row, which makes the computation of G X essentially
as expensive as two matrix vector multiplications. Whenever we have many
classes, this may yield significant computational gains.
Log-likelihood scores of exponential families share similar expansions. We
have
exp w, (x, y ) w, (x, y) = log
l(x, y, W ) = log
y
exp Wy , x Wy , x
y
(3.31)
W l(x, y, W ) =
(ey x) exp Wy , x
y
exp Wy , x
ey x.
(3.32)
The main difference to the soft-margin setting is that the gradients are
not sparse in the number of classes. This means that the computation of
gradients is slightly more costly.
A3.1.4.2 Ontologies
Fig. A3.1. Two ontologies. Left: a binary hierarchy with internal nodes {1, . . . , 7}
and labels {8, . . . 15}. Right: a generic directed acyclic graph with internal nodes
{1, . . . , 6, 12} and labels {7, . . . , 11, 13, . . . , 15}. Note that node 5 has two parents,
namely nodes 2 and 3. Moreover, the labels need not be found at the same level of
the tree: nodes 14 and 15 are one level lower than the rest of the nodes.
259
260
3 Loss Functions
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
The same reasoning applies to estimation when using an exponential families model. The only difference is that we need to compute a soft-max
over paths rather than exclusively choosing the best path over the ontology. Again, a breadth-first recursion suffices: each of the leaves y of the
DAG is associated with a probability p(y|x). To obtain Eyp(y|x) [(y)] all
we need to do is perform a bottom-up traversal of the DAG summing over
all probability weights on the path. Wherever a node has more than one
parent, we distribute the probability weight equally over its parents.
Bibliography
[ABB+ 00] M. Ashburner, C. A. Ball, J. A. Blake, D. Botstein, H. Butler, J. M.
Cherry, A. P. Davis, K. Dolinski, S. S. Dwight, J. T. Eppig, M. A. Harris,
D. P. Hill, L. Issel-Tarver, A. Kasarskis, S. Lewis, J. C. Matese, J. E. Richardson, M. Ringwald, G. M. Rubin, and G. Sherlock, Gene ontology: tool for the
unification of biology. the gene ontology consortium, Nat Genet 25 (2000), 25
29.
[ADSM06] J. Anemuller, J.-R. Duann, T. J. Sejnowski, and S. Makeig, Spatiotemporal dynamics in fmri recordings revealed with complex independent component analysis, Neurocomputing 69 (2006), 15021512.
[AG92] M. Arcones and E. Gine, On the bootstrap of u and v statistics, The Annals
of Statistics 20 (1992), no. 2, 655674.
[AGML90] S. F. Altschul, W. Gish, E. W. Myers, and D. J. Lipman, Basic local
alignment search tool, Journal of Molecular Biology 215 (1990), no. 3, 403
410.
[AHT94] N. Anderson, P. Hall, and D. Titterington, Two-sample test statistics
for measuring discrepancies between two multivariate probability density functions using kernel-based density estimates, Journal of Multivariate Analysis 50
(1994), 4154.
[AS06] Y. Altun and A.J. Smola, Unifying divergence minimization and statistical
inference via convex duality, Proc. Annual Conf. Computational Learning Theory (H.U. Simon and G. Lugosi, eds.), LNCS, Springer, 2006, pp. 139153.
[ATH03] S. Andrews, I. Tsochantaridis, and T. Hofmann, Support vector machines
for multiple-instance learning, Advances in Neural Information Processing Systems 15 (S. Becker, S. Thrun, and K. Obermayer, eds.), MIT Press, 2003.
[BBCP07] S. Ben-David, J. Blitzer, K. Crammer, and F. Pereira, Analysis of representations for domain adaptation, NIPS 19, MIT Press, 2007, pp. 137144.
[BBL05] O. Bousquet, S. Boucheron, and G. Lugosi, Theory of classification: a survey of recent advances, ESAIM: Probab. Stat. 9 (2005), 323 375.
[BCR84] C. Berg, J. P. R. Christensen, and P. Ressel, Harmonic analysis on semigroups, Springer, New York, 1984.
[Bel61] R. E. Bellman, Adaptive control processes, Princeton University Press,
Princeton, NJ, 1961.
[Bel05] Alexandre Belloni, Introduction to bundle methods, Tech. report, Operation
Research Center, M.I.T., 2005.
[Ber85] J. O. Berger, Statistical decision theory and Bayesian analysis, Springer,
New York, 1985.
[Bes74] Julian Besag, Spatial interaction and the statistical analysis of lattice systems
(with discussion), Journal of the Royal Statistical Society. Series B 36 (1974),
no. 2, 192236.
[BG05] G. Biau and L. Gyorfi, On the asymptotic properties of a nonparametric
l1 -test statistic of homogeneity, IEEE Transactions on Information Theory 51
(2005), no. 11, 39653973.
261
262
3 Bibliography
Bibliography
263
264
3 Bibliography
ularized maximum entropy density estimation, Proc. Annual Conf. Computational Learning Theory, Springer Verlag, 2004.
[DS06] M. Dudk and R. E. Schapire, Maximum entropy distribution estimation with
generalized regularization, Proc. Annual Conf. Computational Learning Theory
(G
abor Lugosi and Hans U. Simon, eds.), Springer Verlag, June 2006.
[Dud02] R. M. Dudley, Real analysis and probability, Cambridge University Press,
Cambridge, UK, 2002.
[Fel71] W. Feller, An introduction to probability theory and its applications, 2 ed.,
John Wiley and Sons, New York, 1971.
[Feu93] Andrey Feuerverger, A consistent test for bivariate dependence, International Statistical Review 61 (1993), no. 3, 419433.
[FGSS08] K. Fukumizu, A. Gretton, X. Sun, and B. Scholkopf, Kernel measures of
conditional dependence, Advances in Neural Information Processing Systems
20 (Cambridge, MA), MIT Press, 2008, pp. 489496.
[FJ95] A. Frieze and M. Jerrum, An analysis of a monte carlo algorithm for estimating the permanent, Combinatorica 15 (1995), no. 1, 6783.
[FM53] R. Fortet and E. Mourier, Convergence de la reparation empirique vers la
Bibliography
265
266
3 Bibliography
2008, To Appear.
[JV87] R. Jonker and A. Volgenant, A shortest augmenting path algorithm for dense
and sparse linear assignment problems, Computing 38 (1987), 325340.
[Kan95] A. Kankainen, Consistent testing of total independence based on the empirical characteristic function, Ph.D. thesis, University of Jyvaskyla, 1995.
[Kar80] R.M. Karp, An algorithm to solve the m n assignment problem in expected
time O(mn log n), Networks 10 (1980), no. 2, 143152.
[KBG04] D. Kifer, S. Ben-David, and J. Gehrke, Detecting change in data streams,
Very Large Databases (VLDB), 2004.
[KD05] S. S. Keerthi and D. DeCoste, A modified finite Newton method for fast
solution of large scale linear SVMs, J. Mach. Learn. Res. 6 (2005), 341361.
[Kel60] J. E. Kelly, The cutting-plane method for solving convex programs, Journal
of the Society for Industrial and Applied Mathematics 8 (1960), no. 4, 703712.
[KF09] D. Koller and N. Friedman, Probabilistic graphical models: Principles and
techniques, MIT Press, 2009.
[Kiw90] Krzysztof C. Kiwiel, Proximity control in bundle methods for convex nondifferentiable minimization, Mathematical Programming 46 (1990), 105122.
[KM00] Paul Komarek and Andrew Moore, A dynamic adaptation of AD-trees for
efficient machine learning on large data sets, Proc. Intl. Conf. Machine Learning, Morgan Kaufmann, San Francisco, CA, 2000, pp. 495502.
[KMH94] A. Krogh, I. S. Mian, and D. Haussler, A hidden Markov model that finds
genes in e. coli DNA, Nucleic Acids Research 22 (1994), 47684778.
[Koe05] R. Koenker, Quantile regression, Cambridge University Press, 2005.
[Kuh55] H.W. Kuhn, The Hungarian method for the assignment problem, Naval Research Logistics Quarterly 2 (1955), 8397.
[LBBH98] Y. LeCun, L. Bottou, Y. Bengio, and P. Haffner, Gradient-based learning
applied to document recognition, Proceedings of the IEEE 86 (1998), no. 11,
22782324.
[Lew98] D. D. Lewis, Naive (Bayes) at forty: The independence assumption in information retrieval, Proceedings of ECML-98, 10th European Conference on
Machine Learning (Chemnitz, DE) (C. Nedellec and C. Rouveirol, eds.), no.
1398, Springer Verlag, Heidelberg, DE, 1998, pp. 415.
[LGBS00] T.-W. Lee, M. Girolami, A. Bell, and T. Sejnowski, A unifying framework
for independent component analysis, Comput. Math. Appl. 39 (2000), 121.
[LMP01] J. D. Lafferty, A. McCallum, and F. Pereira, Conditional random fields:
Probabilistic modeling for segmenting and labeling sequence data, Proceedings
of International Conference on Machine Learning (San Francisco, CA), vol. 18,
Morgan Kaufmann, 2001, pp. 282289.
[LNN95] Claude Lemarechal, Arkadii Nemirovskii, and Yurii Nesterov, New variants
of bundle methods, Mathematical Programming 69 (1995), 111147.
[LS07] Q. Le and A.J. Smola, Direct optimization of ranking measures, J. Mach.
Learn. Res. (2007), submitted.
[Lue84] D. G. Luenberger, Linear and nonlinear programming, second ed., AddisonWesley, Reading, May 1984.
[Mac67] J. MacQueen, Some methods of classification and analysis of multivariate
observations, Proc. 5th Berkeley Symposium on Math., Stat., and Prob. (L. M.
LeCam and J. Neyman, eds.), U. California Press, Berkeley, CA, 1967, p. 281.
[Mar61] M.E. Maron, Automatic indexing: An experimental inquiry, Journal of the
Association for Computing Machinery 8 (1961), 404417.
[McA07] David McAllester, Generalization bounds and consistency for structured
Bibliography
267
268
3 Bibliography
[RBZ06] N. Ratliff, J. Bagnell, and M. Zinkevich, Maximum margin planning, International Conference on Machine Learning, July 2006.
[RG99] S. Roweis and Z. Ghahramani, A unifying review of linear Gaussian models,
Neural Computation 11 (1999), no. 2.
[Ros58] F. Rosenblatt, The perceptron: A probabilistic model for information storage
and organization in the brain, Psychological Review 65 (1958), no. 6, 386408.
[Ros05] P. Rosenbaum, An exact distribution-free test comparing two multivariate
distributions based on adjacency, Journal of the Royal Statistical Society B 67
(2005), no. 4, 515530.
[RPB06] M. Richardson, A. Prakash, and E. Brill, Beyond pagerank: machine learning for static ranking, Proceedings of the 15th international conference on
World Wide Web, WWW (L. Carr, D. De Roure, A. Iyengar, C.A. Goble,
and M. Dahlin, eds.), ACM, 2006, pp. 707715.
[RSS+ 07] G. R
atsch, S. Sonnenburg, J. Srinivasan, H. Witte, K.-R. M
uller, R. J.
Sommer, and B. Sch
olkopf, Improving the Caenorhabditis elegans genome annotation using machine learning, PLoS Computational Biology 3 (2007), no. 2,
e20 doi:10.1371/journal.pcbi.0030020.
[RTG00] Y. Rubner, C. Tomasi, and L.J. Guibas, The earth movers distance as a
metric for image retrieval, Int. J. Comput. Vision 40 (2000), no. 2, 99121.
[Rud73] W. Rudin, Functional analysis, McGraw-Hill, New York, 1973.
[SC04] J. Shawe-Taylor and N. Cristianini, Kernel methods for pattern analysis,
Cambridge University Press, Cambridge, UK, 2004.
[Sch97] B. Sch
olkopf, Support vector learning, R. Oldenbourg Verlag, Munich, 1997,
Download: http://www.kernel-machines.org.
[Ser80] R. Serfling, Approximation theorems of mathematical statistics, Wiley, New
York, 1980.
[SGSS07] A.J. Smola, A. Gretton, L. Song, and B. Scholkopf, A hilbert space embedding for distributions, Algorithmic Learning Theory (E. Takimoto, ed.),
Lecture Notes on Computer Science, Springer, 2007.
[Sha48] C. E. Shannon, A mathematical theory of communication, Bell System Technical Journal 27 (1948), 379423, 623656.
[Sha98] R.D. Shachter, Bayes-ball: The rational pasttime, Fourteenth Conference
on Uncertainty in Artificial Intelligence (Wisconsin, USA) (G.F. Cooper and
S. Moral, eds.), Morgan Kaufmann Publishers, Inc., San Francisco, June 1998.
[Sil86] B. W. Silverman, Density estimation for statistical and data analysis, Monographs on statistics and applied probability, Chapman and Hall, London, 1986.
[Smi39] N.V. Smirnov, On the estimation of the discrepancy between empirical curves
of distribution for two independent samples, Bulletin Mathematics 2 (1939),
326, University of Moscow.
[SPST+ 01] B. Sch
olkopf, J. Platt, J. Shawe-Taylor, A. J. Smola, and R. C.
Williamson, Estimating the support of a high-dimensional distribution, Neural Comput. 13 (2001), no. 7, 14431471.
[SS00] A. J. Smola and B. Sch
olkopf, Sparse greedy matrix approximation for machine learning, Proc. Intl. Conf. Machine Learning (San Francisco) (P. Langley,
ed.), Morgan Kaufmann Publishers, 2000, pp. 911918.
[SS02] B. Sch
olkopf and A. Smola, Learning with kernels, MIT Press, Cambridge,
MA, 2002.
[STD07] J. Shawe-Taylor and A. Dolia, A framework for probability density estimation, Proceedings of International Workshop on Artificial Intelligence and
Statistics (M. Meila and X. Shen, eds.), 2007.
Bibliography
269
270
3 Bibliography
[WJ03] M. J. Wainwright and M. I. Jordan, Graphical models, exponential families, and variational inference, Tech. Report 649, UC Berkeley, Department of
Statistics, September 2003.
[WJ08]
, Graphical models, exponential families, and variational inference,
vol. 1, Foundations and Trends in Machine Learning, no. 12, 2008.
[WS01] Christoper K. I. Williams and Matthias Seeger, Using the Nystrom method to
speed up kernel machines, Advances in Neural Information Processing Systems
13 (Cambridge, MA) (T. K. Leen, T. G. Dietterich, and V. Tresp, eds.), MIT
Press, 2001, pp. 682688.
[YAC98] H. H. Yang, S.-I. Amari, and A. Cichocki, Information theoretic approach to
blind separation of sources in non-linear mixture, Signal Processing 64 (1998),
no. 3, 291300.