Line 22: | Line 22: | ||
1 Bayes rule for Gaussian data | 1 Bayes rule for Gaussian data | ||
+ | For a D-dimensional vector <math>\mathbf{x}</math>, the multivariate Gaussian distribution takes the form | ||
+ | <center><math> | ||
+ | p(\mathbf{x}|\mathbf{\mu, \Sigma}) = -\frac{1}{(2\pi)^{D/2}}\frac{1}{|{\mathbf{\Sigma}}|^{1/2}}exp\left[ {-\frac{1}{2}({\mathbf{x}}_n - \mathbf{\mu})^T\mathbf{\Sigma}^{-1}({\mathbf{x}}_n - \mathbf{\mu})} \right] | ||
+ | </math></center> | ||
+ | |||
+ | where <math>\mathbf{\mu}</math> is a D-dimensional mean vector, <math>\mathbf{\Sigma}</math> is a D×D covariance matrix, and <math>|\mathbf{\Sigma}|</math> denotes the determinant of <math>\mathbf{\Sigma}</math>. | ||
---- | ---- | ||
2 Procedure | 2 Procedure | ||
+ | *Obtain training and testing data | ||
+ | We divide the sample data into training set and testing set. Training data is used to estimate the model parameters, and testing data is used to evaluate the accuracy of the classifier. | ||
+ | |||
+ | *Fit a Gaussian model to each class | ||
+ | **Parameter estimation for mean,variance | ||
+ | **Estimate class priors | ||
+ | We will discuss details to estimate these parameters in the following section. | ||
+ | *Calculate and decide | ||
+ | After obtaining the estimated parameters, we can calculate and decide which class a testing sample belongs to using Bayes rule. | ||
---- | ---- | ||
3 Parameter estimation | 3 Parameter estimation | ||
Line 56: | Line 71: | ||
</math></center> | </math></center> | ||
− | + | To estimate the class priors, we will count how much data are there for each class, so | |
+ | <center><math> | ||
+ | P(c_1)\approx N_1/N\\ | ||
+ | P(c_2)\approx N_2/N | ||
+ | </math></center> | ||
---- | ---- | ||
4 Example | 4 Example | ||
+ | |||
+ | *1-D case | ||
+ | |||
+ | *2-D case | ||
---- | ---- |
Revision as of 12:38, 30 April 2014
Bayes rule in practice: definition and parameter estimation
A slecture by ECE student Chuohao Tang
Partly based on the ECE662 Spring 2014 lecture material of Prof. Mireille Boutin.
Content:
1 Bayes rule for Gaussian data
For a D-dimensional vector $ \mathbf{x} $, the multivariate Gaussian distribution takes the form
where $ \mathbf{\mu} $ is a D-dimensional mean vector, $ \mathbf{\Sigma} $ is a D×D covariance matrix, and $ |\mathbf{\Sigma}| $ denotes the determinant of $ \mathbf{\Sigma} $.
2 Procedure
- Obtain training and testing data
We divide the sample data into training set and testing set. Training data is used to estimate the model parameters, and testing data is used to evaluate the accuracy of the classifier.
- Fit a Gaussian model to each class
- Parameter estimation for mean,variance
- Estimate class priors
We will discuss details to estimate these parameters in the following section.
- Calculate and decide
After obtaining the estimated parameters, we can calculate and decide which class a testing sample belongs to using Bayes rule.
3 Parameter estimation
Given a data set $ \mathbf{X}=(\mathbf{x}_1,...,\mathbf{x}_N)^T $ in which the observations $ \{{\mathbf{x}_n}\} $ are assumed to be drawn independently from a multivariate Gaussian distribution (D dimension), we can estimate the parameters of the distribution by maximum likelihood. The log likelihood function is given by
By simple rearrangement, we see that the likelihood function depends on the data set only through the two quantities
These are the sufficient statistics for the Gaussian distribution. The derivative of the log likelihood with respect to $ \mathbf{\mu} $ is
and setting this derivative to zero, we obtain the solution for the maximum likelihood estimate of the mean
Use similar method by setting the derivative of the log likelihood with respect to $ \mathbf{\Sigma} $ to zero, we obtain and setting this derivative to zero, we obtain the solution for the maximum likelihood estimate of the mean
To estimate the class priors, we will count how much data are there for each class, so
4 Example
- 1-D case
- 2-D case
5 Conclusion
Questions and comments
If you have any questions, comments, etc. please post them on this page.