Mathematical background
TThe exact knowledge of prior probabilities and conditional probabilities are generally hard to evaluate thus a parametric approach is often needed. A parametric approach aim to create reasonable hypothesis about the data distribution and its fundamental parameters (e.g mean, variance, …). In the following discussion, we are going to focus only on normal distributions for mathematical convenience but the results could be easily generalized.
Given the multi-dimensional form of Gauss distribution:
where is a -dimensional column vector, is the mean vector of the distribution, is the covariance matrix () and $$ | \Sigma | \Sigma^{-1}\SigmaG\mathbf{x}$$, |
where the exponent () is called Mahalanobis distance of vector from its mean. This distance can be reduced to the Euclidean one when the covariance matrix is the identity matrix ().
The covariance matrix is always symmetric and positive semi-definite by definition (useful information for the next algorithmic strategies) so it is invertible. If the covariance matrix has only diagonal terms the multidimensional distribution can be expressed as the simple product of mono-dimensional normal distributions. In this case the main axes are parallel to the Cartesian axes.
Starting from a multi-variate Gaussian distribution 1, the Bayesian rule for classification problems can be rewritten as:
where, removing constant terms ( factors and the absolute probability density $$p(\mathbf{x}) = \sum_{i=1}^s p(\mathbf{x} | w_i)\cdot P(w_i)$$) and using the monotonicity of the function, we can extract the logarithmic relation: |
which is called Quadratic Discriminant function.
The dependency by the covariance matrix allows 5 different cases:
-
- DiagLinear Classifier
This is the case in which features are completely independent, i.e they have equal variances for each class. This hypothesis allows us to simplify the discriminant function as:
and removing all the constant terms for each class
These simplifications create a linear discriminant function and the separation surfaces between classes are hyper-planes ().
With equal prior probability the function can be rewritten as
which is called nearest mean classifier and the equal-probability surfaces are hyper-spheres.
-
(diagonal matrix) - Linear Classifier
In this case the classes have same covariances but each feature has its own different variance. After the substitution of in the equation, we obtain
where we can remove constant terms (equal for each class) and obtain another time a linear discriminant function and discriminant surfaces given by hyper-planes and equal-probability boundaries given by hyper-ellipsoids. We remark that the only difference from the previous case is the normalization factor of each axis that in this case is given by its variance.
-
(non-diagonal matrix) - Mahalanobis Classifier
In this case we assume that each class has the same covariance matrix but they are non-diagonal ones. The discriminant function becomes
where we can remove the term because it is constant for all the classes and we can assume equal prior probability. In this case we obtain
where the quadratic term is the above told Mahalanobis distance, i.e a normalization of the distance according to the inverse of the covariance matrix. We can prove that expanding the scalar product and removing the constant term, we still obtain a linear discriminant function with the same properties of the previous case. In this case the hyper-ellipsoids have axes aligned to the eigenvectors of the matrix.
-
- DiagQuadratic Classifier
In this case we have a different covariance matrix for each class but they are all proportional to the identity matrix, i.e diagonal matrix. The discriminant function in this case becomes
where this expression can be further reduced obtaining a quadratic discriminant function. In this case the equal-probability boundaries are hyper-spheres aligned to the feature axes.
-
(general case) - Quadratic Classifier
Starting from the more general discriminant function we can relabel the variables and highlight its quadratic form as
In this case each class has its own covariance matrix and the equal-probability boundaries are hyper-ellipsoids oriented to the eigenvectors of the covariance matrix of each class.
The Guassian distribution hypothesis of data should be tested before using this classifiers. It can be evaluated using statistical tests as Malkovich-Afifi based on Kolmogorov-Smirnov index or using the empirical visualization of the data points.
-
In Machine Learning it will correspond to the conditional probability density. ↩