Skewness describes how symmetric distribution is. It is defined as the third moment of the distribution after normalization:
Kurtosis is a measure of tailedness. The heavier the tail is, the larger its Kurtosis is. Mathematically, it is defined as
where is the mean, and is the standard deviation of the distribution of ; and is -th central moment.
It can be shown that the Kurtosis of Gaussian distribution is . People usually use excess Kurtosis as the extra Kurtosis of a distribution compared with standard Gaussian distribution. Namely,
We can create a plot with the square of Skewness as its x-axis and Kurtosis as its y-axis. This plot is called Cullen and Frey graph.
This graph helps us to determine which distribution our data is closest to.
Gaussian mixture model (GMM) is a probability model for a mixture of several Gaussian distributions with possibly different mean and variance.
For example, we can model the 100m race time of all grade 12 students in a high school as two normal distributions: one for female students and one for male students. It is reasonable to expect two groups have different mean and may different variance.
When to use Gaussian mixture model?
1. Data has more than one clusters. In the following picture, the left one models the data with one normal distribution; the right one models the data by two normal distribution, Gaussian mixture model. Obviously, the right one better describes the data.
2. Each cluster is theoretically normally distributed.
Theory of Gaussian Mixture Model
1. Gaussian distribution in 1 dimension Since there are several Gaussian distributions in the GMM. We assign an index to each Gaussian distribution: for where K is the number of clusters. For a given mean and variance , the probability density function is
Above is not the mathematical conditional expectation, but a statistical way of saying we know true parameters in advance.
2. Gaussian mixture model in 1 dimension The probability density function of GMM is the weighted average of several Gaussian densities:
where satisfies
Plug in the Gaussian density,
Note that this is a density function because its integral on is 1.
3. Gaussian mixture model in n-dimension Let be an n-dimension multivariate Gaussian random variable with mean vector and covariance matrix . Then the probability density function is
Then, the probability density function of GMM, which is the weighted average of serveral multivariate Gaussian density, is
with
Training the Model
Suppose that we know the number of clusters a priori. (The choice of relies on statistician’s experience.) Then, we can use Expectation Maximization (EM) algorithm to find the parameters and or for multi-dimensional model. Let be the number of clusters, and be the number of samples.
Step 1: Initialize
Randomly choose samples and set them to be the group mean. For example, in the case of , , . (note that this is also valid for multi-dimensional case)
Set all variances (resp. covariance matrices) to be the same value: sample variance (resp. sample covariance matrix). Namely,
where .
Set all weights equal to , i.e.,
Step 2: Expectation
We compute the probability that a sample belongs to cluster .
Step 3: Maximization
Update parameters then go back to step 2 until converge
Neural network is a convolution of several logistic regressions. It allows some dependence between those regressions. Neural network incorporates more coefficients that will be learned from the date, so it should provide higher accuracy than a single logistic regression. The only thing we need to pay attention is over-fitting.
Here we use neural network with 3 layers (an input layer, a hidden layer, and an output layer) as an example for background information. The case of more layers is quite similar. In this article, our inputs are 25 by 25 pixels images. Since the images are of size , this gives us input layer units (not counting the extra bias unit). The training data will be loaded into the variables and , where is the image, and is the label.
Let be the number of inputs(images in our case), and be the number of possible lables. The cost function for the neural network (without regularization) is
To avoid over-fitting, we use the cost function for neural networks with regularization
When training neural networks, it is important to randomly initialize the parameters for symmetry breaking. One effective strategy for random initialization is to randomly select values for uniformly in the range . We use . This range of values ensures that the parameters are kept small and makes the learning more efficient.
One effective strategy for choosing is to base it on the number of units in the network. A good choice of is , where and are the number of units in the layers adjacent to .
The error of the neural network is obtained by the backpropagation algorithm. The intuition behind the backpropagation algorithm is as follows. Given a training example , we will first run a “forward pass” to compute all the activations throughout the network, including the output value of the hypothesis . Then, for each node in layer , we would like to compute an error term that measures how much that node was responsible for any errors in our output.
For an output node, we can directly measure the difference between the network’s activation and the true target value, and use that to define (since layer 3 is the output layer). For the hidden units, we can compute based on a weighted average of the error terms of the nodes in layer .
Procedure
In detail, here is the backpropagation algorithm. We should implement steps 1 to 4 in a loop that processes one example at a time. Concretely, we should implement a for-loop for and place steps 1-4 below inside the for-loop, with the t-th iteration performing the calculation on the t-th training example . Step 5 will divide the accumulated gradients by to obtain the gradients for the neural network cost function.
Set the input layer’s values to the t-th training example . Perform a feedforward pass (Figure ??), computing the activations for layers 2 and 3. Note that we need to add term to ensure that the vectors of activations for layers and also include the bias unit.
For each output unit in layer 3 (the output layer), set
where indicates whether the current training example belongs to class k (), or if it belongs to a different class ().
For hidden layer , set
Accumulate the gradient from this example using the following formula. Note that we should skip or remove .
Obtain the (unregularized) gradient for the neural network cost function by dividing the accumulated gradients by :
To account for regularization, it turns out that we can add this as an additional term after computing the gradients using backpropagation. Specifically, after we have computed using backpropagation, we should add regularization using
After we have successfully implemented the neural network cost function and gradient computation by feedforward propagation and backpropagation, the next step will be learning a good set of parameters by minimizing the cost function. Since the cost function is not convex, there is no guarantee that we can always find the global minimum. But we should try to increase the number of iterations in our minimizer(say gradient descent, or conjugate descent). And perform the solver several times since the initialization is random, and different initialization may results in different local minimum.