



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




So far, we’ve seen a regression example, and a classification example. In the regression example, we had y|x; θ ∼ N (μ, σ^2 ), and in the classification one, y|x; θ ∼ Bernoulli(φ), for some appropriate definitions of μ and φ as functions of x and θ. In this section, we will show that both of these methods are special cases of a broader family of models, called Generalized Linear Models (GLMs).^1 We will also show how other models in the GLM family can be derived and applied to other classification and regression problems.
To work our way up to GLMs, we will begin by defining exponential family distributions. We say that a class of distributions is in the exponential family if it can be written in the form
p(y; η) = b(y) exp(ηT^ T (y) − a(η)) (3.1)
Here, η is called the natural parameter (also called the canonical param- eter) of the distribution; T (y) is the sufficient statistic (for the distribu- tions we consider, it will often be the case that T (y) = y); and a(η) is the log partition function. The quantity e−a(η)^ essentially plays the role of a nor- malization constant, that makes sure the distribution p(y; η) sums/integrates over y to 1. A fixed choice of T , a and b defines a family (or set) of distributions that is parameterized by η; as we vary η, we then get different distributions within this family.
(^1) The presentation of the material in this section takes inspiration from Michael I.
Jordan, Learning in graphical models (unpublished book draft), and also McCullagh and Nelder, Generalized Linear Models (2nd ed.).
We now show that the Bernoulli and the Gaussian distributions are ex- amples of exponential family distributions. The Bernoulli distribution with mean φ, written Bernoulli(φ), specifies a distribution over y ∈ { 0 , 1 }, so that p(y = 1; φ) = φ; p(y = 0; φ) = 1 − φ. As we vary φ, we obtain Bernoulli distributions with different means. We now show that this class of Bernoulli distributions, ones obtained by varying φ, is in the exponential family; i.e., that there is a choice of T , a and b so that Equation (3.1) becomes exactly the class of Bernoulli distributions. We write the Bernoulli distribution as:
p(y; φ) = φy(1 − φ)^1 −y = exp(y log φ + (1 − y) log(1 − φ))
= exp
log
φ 1 − φ
y + log(1 − φ)
Thus, the natural parameter is given by η = log(φ/(1 − φ)). Interestingly, if we invert this definition for η by solving for φ in terms of η, we obtain φ = 1 /(1 + e−η). This is the familiar sigmoid function! This will come up again when we derive logistic regression as a GLM. To complete the formulation of the Bernoulli distribution as an exponential family distribution, we also have
T (y) = y a(η) = − log(1 − φ) = log(1 + eη) b(y) = 1
This shows that the Bernoulli distribution can be written in the form of Equation (3.1), using an appropriate choice of T , a and b. Let’s now move on to consider the Gaussian distribution. Recall that, when deriving linear regression, the value of σ^2 had no effect on our final choice of θ and hθ(x). Thus, we can choose an arbitrary value for σ^2 without changing anything. To simplify the derivation below, let’s set σ^2 = 1.^2 We
(^2) If we leave σ (^2) as a variable, the Gaussian distribution can also be shown to be in the
exponential family, where η ∈ R^2 is now a 2-dimension vector that depends on both μ and σ. For the purposes of GLMs, however, the σ^2 parameter can also be treated by considering a more general definition of the exponential family: p(y; η, τ ) = b(a, τ ) exp((ηT^ T (y) − a(η))/c(τ )). Here, τ is called the dispersion parameter, and for the Gaussian, c(τ ) = σ^2 ; but given our simplification above, we won’t need the more general definition for the examples we will consider here.
The third of these assumptions might seem the least well justified of the above, and it might be better thought of as a “design choice” in our recipe for designing GLMs, rather than as an assumption per se. These three assumptions/design choices will allow us to derive a very elegant class of learning algorithms, namely GLMs, that have many desirable properties such as ease of learning. Furthermore, the resulting models are often very effective for modelling different types of distributions over y; for example, we will shortly show that both logistic regression and ordinary least squares can both be derived as GLMs.
To show that ordinary least squares is a special case of the GLM family of models, consider the setting where the target variable y (also called the response variable in GLM terminology) is continuous, and we model the conditional distribution of y given x as a Gaussian N (μ, σ^2 ). (Here, μ may depend x.) So, we let the ExponentialF amily(η) distribution above be the Gaussian distribution. As we saw previously, in the formulation of the Gaussian as an exponential family distribution, we had μ = η. So, we have
hθ(x) = E[y|x; θ] = μ = η = θT^ x.
The first equality follows from Assumption 2, above; the second equality follows from the fact that y|x; θ ∼ N (μ, σ^2 ), and so its expected value is given
by μ; the third equality follows from Assumption 1 (and our earlier derivation showing that μ = η in the formulation of the Gaussian as an exponential family distribution); and the last equality follows from Assumption 3.
We now consider logistic regression. Here we are interested in binary classifi- cation, so y ∈ { 0 , 1 }. Given that y is binary-valued, it therefore seems natural to choose the Bernoulli family of distributions to model the conditional dis- tribution of y given x. In our formulation of the Bernoulli distribution as an exponential family distribution, we had φ = 1/(1 + e−η). Furthermore, note that if y|x; θ ∼ Bernoulli(φ), then E[y|x; θ] = φ. So, following a similar derivation as the one for ordinary least squares, we get:
hθ(x) = E[y|x; θ] = φ = 1 /(1 + e−η) = 1 /(1 + e−θ
T (^) x )
So, this gives us hypothesis functions of the form hθ(x) = 1/(1 + e−θ
T (^) x ). If you are previously wondering how we came up with the form of the logistic function 1/(1 + e−z^ ), this gives one answer: Once we assume that y condi- tioned on x is Bernoulli, it arises as a consequence of the definition of GLMs and exponential family distributions. To introduce a little more terminology, the function g giving the distri- bution’s mean as a function of the natural parameter (g(η) = E[T (y); η]) is called the canonical response function. Its inverse, g−^1 , is called the canonical link function. Thus, the canonical response function for the Gaussian family is just the identify function; and the canonical response function for the Bernoulli is the logistic function.^3
(^3) Many texts use g to denote the link function, and g− (^1) to denote the response function;
but the notation we’re using here, inherited from the early machine learning literature, will be more consistent with the notation used in the rest of the class.