



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!




The Naive Bayes model is an old method for classification and predictor selection that is enjoying a renaissance because of its simplicity and stability.
The following notation is used throughout this chapter unless otherwise stated:
J 0 Total number of predictors. X Categorical predictor vector X’ = ( X 1 , ..., X J ), where J is the number of predictors considered. M j Number of categories for predictor X j. Y Categorical target variable. K Number of categories of Y. N Total number of cases or patterns in the training data. N (^) k The number of cases with Y= k in the training data. N jmk The number of cases with Y= k and X j =m in the training data. πk The probability for Y= k. p jmk The probability of X j=m given Y= k.
The Naive Bayes model is based on the conditional independence model of each predictor given the target class. The Bayesian principle is to assign a case to the class that has the largest posterior probability. By Bayes’ theorem, the posterior probability of Y given X is:
Let X 1 , ..., XJ be the J predictors considered in the model. The Naive Bayes model assumes that X 1 , ..., X (^) J are conditionally independent given the target; that is:
These probabilities are estimated from training data by the following equations:
1
Naive Bayes Algorithms
Where N (^) k is calculated based on all non-missing Y, Njmk is based on all non-missing pairs of XJ and Y, and the factors λ and f are introduced to overcome problems caused by zero or very small cell counts. These estimates correspond to Bayesian estimation of the multinomial probabilities with Dirichlet priors. Empirical studies suggest (Kohavi et al., 1997).
A single data pass is needed to collect all the involved counts.
For the special situation in which J = 0; that is, there is no predictor at all,
. When there are empty categories in the target variable or categorical predictors, these empty categories should be removed from the calculations.
A predictor is ignored if every value is missing or if it has only one observed category. A case is ignored if the value of the target variable or the values of all predictors are missing. For each case missing some, but not all, of the values of the predictors, only the predictors with nonmissing values are used to predict the case, as suggested in (Kohavi et al., 1997).
This implies the following equation:
not missing
This also implies the following equation for B(J) in average log-likelihood calculations:
not missing
Where the log() term for case i is ignored if all the values of the predictors considered in the model are missing, and N’ is the total number of terms that are not ignored in the sum. For more information, see “Average Log-likelihood” on p. 4.
The Naive Bayes model assumes that the target and predictor variables are categorical. If there are continuous variables, they need to be discretized. There are many ways to discretize a continuous variable; the simplest is to divide the domain of a variable into equal width bins. This method performs well with the Naive Bayes model while no obvious improvement is found when complex methods are used (Hsu et al., 2000).
Sometimes the equal width binning method may produce empty bins. In this case, empty bins are eliminated by changing bin boundary points. Let b 1 < b 2 < ... bn be the bin boundary points produced by the equal width binning method. The two end bins (-∞, b 1 ] and (bn , ∞) are non-empty by design. Suppose that bin (bi , bi+1 ] is empty, and suppose that the closest left
Naive Bayes Algorithms
If you specify an exact number of predictors, the final subset in the sequence is the final model. If you specify a maximum number of predictors, the “best” subset is determined by one of the following: A test data criterion based on the average log-likelihood of the test data. A pseudo-BIC criterion that uses the average log-likelihood of the training data and penalizes overly complex models using the number of predictors and number of cases. This criterion is used if there are no test data. Smaller values of these criteria indicate “better” models. The “best” subset is the one with the smallest value of the criterion used.
Test Data Criterion
Test
Where Test is the average log-likelihood for test data.
Pseudo-BIC Criterion
Train
Where J denotes the number of predictors in the model, and (^) Train is the average log-likelihood for training data.
The average (conditional) log-likelihood for data with J predictors is
Let
Naive Bayes Algorithms
then
Note: for the special situation in which J = 0; that is, there are no predictors,
Calculation of average log-likelihood by sampling
When adding each predictor to the sequence of subsets, a data pass is needed to calculate B(J). When the data set is small enough to fit in the memory, this is not a problem. When the data set cannot fit in memory, this can be costly. The Naive Bayes model uses simulated data to calculate B(J). Other research has shown that this approach yields good results. The formula for B(J) can be rewritten as, for a data set of m cases:
By default m = 1000.
The target category with the highest posterior probability is the predicted category for a given case.
argmax argmax
Ties are broken in favor of the target category with greater prior probability πk.
When cases being classified contain categories of categorical predictors that did not occur in the training data, these new categories are treated as missing.
If there is test data, the error equals the misclassification ratio of the test data. If there is no test data, the error equals the misclassification ratio of the training data.
Bayes, T. 1763. An essay towards solving a problem in the doctrine of chances. Philosophical Transactions of the Royal Society , 53, 370–418.
Bayes, T. 1763. An essay towards solving a problem in the doctrine of chances. Philosophical Transactions of the Royal Society , 53, 370–418.
Becker, B., R. Kohavi, and D. Sommerfield. 2001. Visualizing the Simple Bayesian Classifier. In: Information Visualization in Data Mining and Knowledge Discovery, U. Fayyad, G. Grinstein, and A. Wierse, eds. San Francisco: Morgan Kaufmann Publishers, 237–249.
Domingos, P., and M. J. Pazzani. 1996. Beyond Independence: conditions for the optimality of the simple Bayesian classifier. In: Machine Learning: Proceedings of the Thirteenth International Conference, L. Saitta, ed., 105–112.
Hsu, C., H. Huang, and T. Wong. 2000. Why Discretization Works for Naive Bayesian Classifiers. In: Proceedings of the 17th International Conference on Machine Learning, San Francisco: MorganKaufman, 399–406.
Kohavi, R., and D. Sommerfield. 1995. Feature subset selection using the wrapper model: Overfitting and dynamic search space topology. In: The First International Conference on Knowledge Discovery and Data Mining, Menlo Park, California: AAAIPress, 192–197.
Kohavi, R., B. Becker, and D. Sommerfield. 1997. Improving Simple Bayes. In: Proceedings of the European Conference on Machine Learning, , 78–87.
Natarajan, R., and E. Pednault. 2001. Using Simulated Pseudo Data to Speed Up Statistical Predictive Modeling from Massive Data Sets. In: SIAM First International Conference on Data Mining,.
7