The sigmoid function and softmax function are commonly used in the field of machine learning. And they are like “least square error” in linear regression. They can be derived from certain basic assumptions using the general form of Exponential family. Some of the basic linear regression and classification algorithms can also be derived from the general form. Let’s dig deep and see how we obtain the myterious functions.
Exponential family includes the Gaussian, binomial, multinomial, Poisson, Gamma and many others distributions. Loosely speaking, a distribution belongs to exponential family if it can be transformed into the general form:
\(\eta\) is canonical parameter
\(T(x)\) is sufficient statistic
\(A(\eta)\) is cumulant function
The regularity conditions of exponential family is mathematically rigorous. It can be referred here: http://stats.stackexchange.com/questions/187533/exponential-family-regularity-conditions
Nice properties of the general form
The general form of exponential family contains nice properties for constructing machine learning models.
First derivative of the cumulant function is mean, while second derivative is the variance of the corresponding distribution. The cumulant generating function of exponential family distributions can be considered as \(A(\eta\)), which can be treated as an alternative way to calculate moments of a distribution. For moment generating function, we need to calculate the integral, however, for cumulant generating function, we just have to calculate the derivative, which is much more simple.
Obtaining sufficient statistics
The sufficient statistics, \(T(x)\), can be obtained by inspection. The intuitive explaination of sufficiency is: Having observed \(T(x)\), we can throw away \(X\) for the purposes of inference with respect to \(\theta\).
For example, \(T(x)=x\) is sufficient statistics for bernoulli distribution and \(T(x)=[x,x^2]\) is the sufficient statistics of gaussian distribution
Obtaining a general formula for maximum likelihood estimation
We can obtain a generalised formula for maximum likelihood estimates of the parameters in exponential family distributions. For example, for mean estimation, we have:
Transforming distributions into general form
It is easy to transform a distribution into the general form. And we can gain insight from the general form.
Consider Bernoulli distribution
Solving \(\pi\) in terms of \(\eta\), we have:
, which is the sigmoid function.
Similarly, we can transform the multinomial distribution and obtain:
,which is the softmax function.
We can also derive regression models using the distributions in exponential family. For example:
- By having assumption that data follows gaussian noise, we can use gaussian distribution to model it, which give rise to least square error
- For two-class classification problems, we can model it using bernoulli distribution, which give rise to binary classification using sigmoid function
- For multi-class classification, we can model it using multinomial distribution, which give rise to multi-class classification using softmax function.
Moreover, other models like poisson regression can also be derived from the general form of exponential family. The method of plugging in a desired distribution under assumptions is called generalised linear model.