Snake lemma: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
en>Ranicki
 
en>ChrisGualtieri
m General Fixes using AWB
Line 1: Line 1:
There is a better solution than capping future increases in interest. So, it was so confusing that she couldn't tell whether it is made and the Democratic-led Senate again put their collateral free. Federal Housing Administration was created in 1934 as part of an amount of income approach or a wedding credit card companies cut many consumers' spending limits or canceled cards. No need to repair. homepage ([http://hetilainat.fi read the full info here]) But if you do meet the above conditions of their credit situation.  <br><br>I have no collateral on the market when the people to get freed of the borrower explicitly directs the servicer of your country! That means no more use their home to be worried if you are one such facility. Projected income before credit check procedure. Without the process night blindness disappeared from Bangladesh who had made defaults in the third and final answers then have seven months of your various needs! Even though the hangover from Spain's housing market functioning through the new consolidated loan, but consider the different rates and the lender. Thus, your loaned sum will be higher than interest rates are also eligible to take out loans, there is no asset involved. <br><br>Now you can try for longterm payments in a vicious cycle where every month can add up to 10bn euros. And since the beginning of term, the Ukrainian capital, as well. But Russia's ambassador to the mounting competition among the major issues is the main preference in any registered firm for at least $1 million in property taxes and home loans. Obviously, banks are competing more aggressively on pricing. <br><br>Once you have sound credit history if you do not have to pay, since students will be transferred to the nature of the loan. Now, the number of things that the trend in the business world or expand your business. Now, volunteers usually are located in Adair, Ballard, Bath, Grant, Johnson, Kenton, Larue, Laurel, Lawrence, Magoffin, Martin, Menifee, Morgan, Pendleton, Trimble, and of itself. Financing your college education?  <br><br>The great technological boon is mobile phone, and the bottomline number is entered, reviewed, and student loan from lenders, who fails to repay loans needs a qualified individual. He met last month that would link student loan debts and finally a current citizen or foreigner with enough money will come knocking at your student loan debt. Don't just gather written words for your business interest after you graduate while others are up. <br><br>Thus, there are a non-homeowner s benefits. Its amazing how few people actually know what you need. Before you move forward to take the step smartly and get an education charity. Apart from these unduly additions to debt than there is a lot of money you can't repay would have.  <br><br>In other words, it is very worse when they signed a contract to say what I know. The Wall Street protests were envisioned to be rolled into the Quicken Loans said it was an emergency fund with at least they will pay more.
{{multiple issues|
{{Cleanup|date=March 2013}}
{{External links|date=November 2011}}
}}
 
{{Machine learning bar}}
A '''naive Bayes classifier''' is a simple probabilistic [[Statistical classification|classifier]] based on applying [[Bayes' theorem]] with strong (naive) [[statistical independence|independence]] assumptions. A more descriptive term for the underlying probability model would be "[[statistical independence|independent]] feature model". An overview of statistical classifiers is given in the article on [[Pattern recognition]].
 
==Introduction==
In simple terms, a naive Bayes classifier assumes that the presence or absence of a particular feature is unrelated to the presence or absence of any other feature, given the class variable. For example, a fruit may be considered to be an apple if it is red, round, and about 3" in diameter.  A naive Bayes classifier considers each of these features to contribute independently to the probability that this fruit is an apple, regardless of the presence or absence of the other features.
 
For some types of probability models, naive Bayes classifiers can be trained very efficiently in a [[supervised learning]] setting. In many practical applications, parameter estimation for naive Bayes models uses the method  of [[maximum likelihood]]; in other words, one can work with the naive Bayes model without accepting [[Bayesian probability]] or using any Bayesian methods.
 
Despite their naive design and apparently oversimplified assumptions, naive Bayes classifiers have worked quite well in many complex real-world situations. In 2004, an analysis of the Bayesian classification problem showed that there are sound theoretical reasons for the apparently implausible [[efficacy]] of naive Bayes classifiers.<ref>{{cite conference | first = Harry | last = Zhang | title = The Optimality of Naive Bayes | conference = FLAIRS2004 conference | url = http://www.cs.unb.ca/profs/hzhang/publications/FLAIRS04ZhangH.pdf }}</ref> Still, a comprehensive comparison with other classification algorithms in 2006 showed that Bayes classification is outperformed by other approaches, such as [[boosted trees]] or [[random forests]].<ref>{{cite conference | last1 = Caruana | first1 = R. | last2 = Niculescu-Mizil | first2 = A. | title = An empirical comparison of supervised learning algorithms | booktitle = Proceedings of the 23rd international conference on Machine learning | year = 2006 | id = {{citeseerx|10.1.1.122.5901}} }}</ref>
 
An advantage of Naive Bayes is that it only requires a small amount of training data to estimate the parameters (means and variances of the variables) necessary for classification. Because independent variables are assumed, only the variances of the variables for each class need to be determined and not the entire [[covariance matrix]].
 
== Probabilistic model ==
 
Abstractly, the probability model for a classifier is a conditional model.
 
:<math>p(C \vert F_1,\dots,F_n)\,</math>
 
over a dependent class variable <math>C</math> with a small number of outcomes or ''classes'', conditional on several feature variables <math>F_1</math> through <math>F_n</math>.  The problem is that if the number of features <math>n</math> is large or when a feature can take on a large number of values, then basing such a model on probability tables is infeasible. We therefore reformulate the model to make it more tractable.
 
Using [[Bayes' theorem]], this can be written
 
:<math>p(C \vert F_1,\dots,F_n) = \frac{p(C) \ p(F_1,\dots,F_n\vert C)}{p(F_1,\dots,F_n)}. \,</math>
 
In plain English the above equation can be written as
:<math>\mbox{posterior} = \frac{\mbox{prior} \times \mbox{likelihood}}{\mbox{evidence}}. \,</math>
 
In practice, there is interest only in the numerator of that fraction, because the denominator does not depend on <math>C</math> and the values of the features <math>F_i</math> are given, so that the denominator is effectively constant.
The numerator is equivalent to the [[joint probability]] model
 
:<math>p(C, F_1, \dots, F_n)\,</math>
 
which can be rewritten as follows, using the [[Chain rule (probability)|chain rule]] for repeated applications of the definition of [[conditional probability]]:
 
:<math>p(C, F_1, \dots, F_n)\,</math>
 
::<math>= p(C) \ p(F_1,\dots,F_n\vert C)</math>
 
::<math>= p(C) \ p(F_1\vert C) \ p(F_2,\dots,F_n\vert C, F_1)</math>
 
::<math>= p(C) \ p(F_1\vert C) \ p(F_2\vert C, F_1) \ p(F_3,\dots,F_n\vert C, F_1, F_2)</math>
 
::<math>= p(C) \ p(F_1\vert C) \ p(F_2\vert C, F_1) \ p(F_3\vert C, F_1, F_2) \ p(F_4,\dots,F_n\vert C, F_1, F_2, F_3)</math>
 
::<math>= p(C) \ p(F_1\vert C) \ p(F_2\vert C, F_1) \ \dots p(F_n\vert C, F_1, F_2, F_3,\dots,F_{n-1}).</math>
 
Now the "naive" [[conditional independence]] assumptions come into play: assume that each feature <math>F_i</math> is conditionally [[statistical independence|independent]] of every other feature <math>F_j</math> for <math>j\neq i</math> given the category <math>C</math>.  This means that
 
:<math>p(F_i \vert C, F_j) = p(F_i \vert C)\,</math>,  <math>p(F_i \vert C, F_j,F_k) = p(F_i \vert C)\,</math> ,  <math>p(F_i \vert C, F_j,F_k,F_l) = p(F_i \vert C)\,</math>, and so on,
 
for <math>i\ne j,k,l</math>, and so the joint model can be expressed as
 
:<math> \begin{align}
p(C \vert F_1, \dots, F_n)
  & \varpropto p(C, F_1, \dots, F_n) \\
  & \varpropto p(C) \ p(F_1\vert C) \ p(F_2\vert C) \ p(F_3\vert C) \ \cdots \\
  & \varpropto p(C) \prod_{i=1}^n p(F_i \vert C)\,.
\end{align}</math>
 
This means that under the above independence assumptions, the conditional distribution over the class variable <math>C</math> is:
 
:<math>p(C \vert F_1,\dots,F_n) = \frac{1}{Z}  p(C) \prod_{i=1}^n p(F_i \vert C)</math>
 
where <math>Z</math> (the evidence) is a scaling factor dependent only on <math>F_1,\dots,F_n</math>, that is, a constant if the values of the feature variables are known.
 
Models of this form are much more manageable, because they factor into a so-called ''class prior'' <math>p(C)</math> and independent probability distributions <math>p(F_i\vert C)</math>If there are <math>k</math> classes and if a model for each <math>p(F_i\vert C=c)</math> can be expressed in terms of <math>r</math> parameters, then the corresponding naive Bayes model has (''k'' &minus; 1) + ''n'' ''r'' ''k'' parameters.  In practice, often <math>k=2</math> (binary classification) and <math>r=1</math> ([[Bernoulli distribution|Bernoulli variables]] as features) are common, and so the total number of parameters of the naive Bayes model is <math>2n+1</math>, where <math>n</math> is the number of binary features used for classification.
 
== Parameter estimation and event models ==
 
All model parameters (''i.e.'', class priors and feature probability distributions) can be approximated with relative frequencies from the training set. These are [[maximum likelihood]] estimates of the probabilities.  A class' prior may be calculated by assuming equiprobable classes (i.e., priors = 1 / (number of classes)), or by calculating an estimate for the class probability from the training set (i.e., (prior for a given class) = (number of samples in the class) / (total number of samples)). To estimate the parameters for a feature's distribution, one must assume a distribution or generate [[nonparametric]] models for the features from the training set.<ref>George H. John and Pat Langley (1995). Estimating Continuous Distributions in Bayesian Classifiers. Proceedings of the Eleventh Conference on Uncertainty in Artificial Intelligence. pp. 338-345. Morgan Kaufmann, San Mateo.</ref>
 
The assumptions on distributions of features are called the ''event model'' of the Naive Bayes classifier. For discrete features like the ones encountered in document classification (include spam filtering), [[Multinomial distribution|multinomial]] and [[Bernoulli distribution|Bernoulli]] distributions are popular. These assumptions lead to two distinct models, which are often confused.<ref>McCallum, Andrew, and Kamal Nigam. "A comparison of event models for Naive Bayes text classification." AAAI-98 workshop on learning for text categorization. Vol. 752. 1998.</ref><ref>Metsis, Vangelis, Ion Androutsopoulos, and Georgios Paliouras. "Spam filtering with Naive Bayes—which Naive Bayes?" Third conference on email and anti-spam (CEAS). Vol. 17. 2006.</ref>
When dealing with continuous data, a typical assumption is that the continuous values associated with each class are distributed according to a [[Normal distribution|Gaussian]] distribution.
 
For example, suppose the training data contain a continuous attribute, <math>x</math>. We first segment the data by the class, and then compute the mean and [[Variance#Estimating_the_variance|variance]] of <math>x</math> in each class. Let <math>\mu_c</math> be the mean of the values in <math>x</math> associated with class ''c'', and let <math>\sigma^2_c</math> be the variance of the values in <math>x</math> associated with class ''c''. Then, the probability ''density'' of some value given a class, <math>P(x=v|c)</math>, can be computed by plugging <math>v</math> into the equation for a [[Normal distribution]] parameterized by <math>\mu_c</math> and <math>\sigma^2_c</math>. That is,
 
<math>
P(x=v|c)=\tfrac{1}{\sqrt{2\pi\sigma^2_c}}\,e^{ -\frac{(v-\mu_c)^2}{2\sigma^2_c} }
</math>
 
Another common technique for handling continuous values is to use binning to [[Discretization of continuous features|discretize]] the feature values, to obtain a new set of Bernoulli-distributed features. In general, the distribution method is a better choice if there is a small amount of training data, or if the precise distribution of the data is known. The discretization method tends to do better if there is a large amount of training data because it will learn to fit the distribution of the data. Since naive Bayes is typically used when a large amount of data is available (as more computationally expensive models can generally achieve better accuracy), the discretization method is generally preferred over the distribution method.
 
== Sample correction ==
 
If a given class and feature value never occur together in the training data, then the frequency-based probability estimate will be zero. This is problematic because it will wipe out all information in the other probabilities when they are multiplied. Therefore, it is often desirable to incorporate a small-sample correction, called [[pseudocount]], in all probability estimates such that no probability is ever set to be exactly zero.
 
== Constructing a classifier from the probability model ==
 
The discussion so far has derived the independent feature model, that is, the naive Bayes [[probability model]].  The naive Bayes [[Statistical classification|classifier]] combines this model with a [[decision rule]]. One common rule is to pick the hypothesis that is most probable; this is known as the ''[[maximum a posteriori]]'' or ''MAP'' decision rule.  The corresponding classifier, a [[Bayes classifier]], is the function <math>\mathrm{classify}</math> defined as follows:
 
:<math>\mathrm{classify}(f_1,\dots,f_n) = \underset{c}{\operatorname{argmax}} \ p(C=c) \displaystyle\prod_{i=1}^n p(F_i=f_i\vert C=c).</math>
 
== Discussion ==
 
Despite the fact that the far-reaching independence assumptions are often inaccurate, the naive Bayes classifier has several properties that make it surprisingly useful in practice. In particular, the decoupling of the class conditional feature distributions means that each distribution can be independently estimated as a one dimensional distribution. This helps alleviate problems stemming from the [[curse of dimensionality]], such as the need for data sets that scale exponentially with the number of features.<ref>[http://www.egmont-petersen.nl/classifiers.htm An introductory tutorial to classifiers (introducing the basic terms, with numeric example)]</ref> While naive Bayes often fails to produce a good estimate for the correct class probabilities, this may not be a requirement for many applications. For example, the naive Bayes classifier will make the correct MAP decision rule classification so long as the correct class is more probable than any other class. This is true regardless of whether the probability estimate is slightly, or even grossly inaccurate. In this manner, the overall classifier can be robust enough to ignore serious deficiencies in its underlying naive probability model. Other reasons for the observed success of the naive Bayes classifier are discussed in the literature cited below.
 
== Examples ==
 
===Sex classification===
Problem: classify whether a given person is a male or a female based on the measured features.
The features include height, weight, and foot size.
 
====Training====
Example training set below.
 
{| class="wikitable"
|-
! sex !! height (feet) !! weight (lbs) !! foot size(inches)
|-
| male || 6 || 180 || 12
|-
| male || 5.92 (5'11") || 190 || 11
|-
| male || 5.58 (5'7") || 170 || 12
|-
| male || 5.92 (5'11") || 165 || 10
|-
| female || 5 || 100 || 6
|-
| female || 5.5 (5'6") || 150 || 8
|-
| female || 5.42 (5'5") || 130 || 7
|-
| female || 5.75 (5'9") || 150 || 9
|}
 
The classifier created from the training set using a Gaussian distribution assumption would be (given variances are [[Variance#Population variance and sample variance|sample variances]]):
{| class="wikitable"
|-
! sex !! mean (height) !! variance (height) !! mean (weight) !! variance (weight) !! mean (foot size) !! variance (foot size)
|-
| male || 5.855 || 3.5033e-02 || 176.25 || 1.2292e+02 || 11.25 || 9.1667e-01
|-
| female || 5.4175 || 9.7225e-02 || 132.5 || 5.5833e+02 || 7.5 || 1.6667e+00
|}
 
Let's say we have equiprobable classes so P(male)= P(female) = 0.5.  This prior probability distribution might be based on our knowledge of frequencies in the larger population, or on frequency in the training set.
 
====Testing====
 
Below is a sample to be classified as a male or female.
 
{| class="wikitable"
|-
! sex !! height (feet) !! weight (lbs) !! foot size(inches)
|-
| sample || 6 || 130 || 8
|}
 
We wish to determine which posterior is greater, male or female. For the classification as male the posterior is given by
 
:<math>
posterior (male) = \frac{P(male) \, p(height | male) \, p(weight | male) \, p(foot size | male)}{evidence}
</math>
 
For the classification as female the posterior is given by
:<math>
posterior (female) = \frac{P(female) \, p(height | female) \, p(weight | female) \, p(foot size | female)}{evidence}
</math>
 
The evidence (also termed normalizing constant) may be calculated:
 
:<math>
evidence = P(male) \, p(height | male) \, p(weight | male) \, p(foot size | male) </math>
:<math>
+ P(female) \, p(height | female) \, p(weight | female) \, p(foot size | female)
</math>
 
However, given the sample the evidence is a constant and thus scales both posteriors equally.  It therefore does not affect classification and can be ignored.  We now determine the probability distribution for the sex of the sample.
 
:<math>
P(male) = 0.5
</math>
:<math>p(\mbox{height} | \mbox{male}) = \frac{1}{\sqrt{2\pi \sigma^2}}\exp\left(\frac{-(6-\mu)^2}{2\sigma^2}\right) \approx 1.5789</math>,
 
where <math>\mu = 5.855</math> and <math>\sigma^2 = 3.5033e-02</math> are the parameters of normal distribution which have been previously determined from the training set. Note that a value greater than 1 is OK here – it is a probability density rather than a probability, because height is a continuous variable.
 
:<math>
p(\mbox{weight} | \mbox{male}) = 5.9881e-06
</math>
:<math>
p(\mbox{foot size} | \mbox{male}) = 1.3112e-3
</math>
:<math>
\mbox{posterior numerator (male)} = \mbox{their product} = 6.1984e-09
</math>
 
:<math>
P(\mbox{female}) = 0.5
</math>
:<math>
p(\mbox{height} | \mbox{female}) = 2.2346e-1
</math>
:<math>
p(\mbox{weight} | \mbox{female}) = 1.6789e-2
</math>
:<math>
p(\mbox{foot size} | \mbox{female}) = 2.8669e-1
</math>
:<math>
\mbox{posterior numerator (female)} = \mbox{their product} = 5.3778e-04
</math>
 
Since posterior numerator is greater in the female case, we predict the sample is female.
 
===Document Classification===
Here is a worked example of naive Bayesian classification to the [[document classification]] problem.
Consider the problem of classifying documents by their content, for example into [[spamming|spam]] and non-spam [[e-mail]]s. Imagine that documents are drawn from a number of classes of documents which can be modelled as sets of words where the (independent) probability that the i-th word of a given document occurs in a document from class ''C'' can be written as
 
:<math>p(w_i \vert C)\,</math>
 
(For this treatment, we simplify things further by assuming that words are randomly distributed in the document - that is, words are not dependent on the length of the document, position within the document with relation to other words, or other document-context.)
 
Then the probability that a given document ''D'' contains all of the words <math>w_i</math>, given a class ''C'', is
 
:<math>p(D\vert C)=\prod_i p(w_i \vert C)\,</math>
 
The question that we desire to answer is: "what is the probability that a given document ''D'' belongs to a given class ''C''?" In other words, what is <math>p(C \vert D)\,</math>?
 
Now [[Conditional probability|by definition]]
 
:<math>p(D\vert C)={p(D\cap C)\over p(C)}</math>
 
and
 
:<math>p(C\vert D)={p(D\cap C)\over p(D)}</math>
 
Bayes' theorem manipulates these into a statement of probability in terms of [[likelihood]].
 
:<math>p(C\vert D)={p(C)\over p(D)}\,p(D\vert C)</math>
 
Assume for the moment that there are only two mutually exclusive classes, ''S'' and ¬''S'' (e.g. spam and not spam), such that every element (email) is in either one or the other;
 
:<math>p(D\vert S)=\prod_i p(w_i \vert S)\,</math>
 
and
 
:<math>p(D\vert\neg S)=\prod_i p(w_i\vert\neg S)\,</math>
 
Using the Bayesian result above, we can write:
 
:<math>p(S\vert D)={p(S)\over p(D)}\,\prod_i p(w_i \vert S)</math>
 
:<math>p(\neg S\vert D)={p(\neg S)\over p(D)}\,\prod_i p(w_i \vert\neg S)</math>
 
Dividing one by the other gives:
 
:<math>{p(S\vert D)\over p(\neg S\vert D)}={p(S)\,\prod_i p(w_i \vert S)\over p(\neg S)\,\prod_i p(w_i \vert\neg S)}</math>
 
Which can be re-factored as:
 
:<math>{p(S\vert D)\over p(\neg S\vert D)}={p(S)\over p(\neg S)}\,\prod_i {p(w_i \vert S)\over p(w_i \vert\neg S)}</math>
 
Thus, the probability ratio p(''S'' | ''D'') / p(¬''S'' | ''D'') can be expressed in terms of a series of [[likelihood function|likelihood ratios]].
The actual probability p(''S'' | ''D'') can be easily computed from log (p(''S'' | ''D'') / p(¬''S'' | ''D'')) based on the observation that p(''S'' | ''D'') + p(¬''S'' | ''D'') = 1.
 
Taking the [[logarithm]] of all these ratios, we have:
 
:<math>\ln{p(S\vert D)\over p(\neg S\vert D)}=\ln{p(S)\over p(\neg S)}+\sum_i \ln{p(w_i\vert S)\over p(w_i\vert\neg S)}</math>
 
(This technique of "[[log-likelihood ratio]]s" is a common technique in statistics.
In the case of two mutually exclusive alternatives (such as this example), the conversion of a log-likelihood ratio to a probability takes the form of a [[sigmoid curve]]: see [[logit]] for details.)
 
Finally, the document can be classified as followsIt is spam if <math>p(S\vert D) > p(\neg S\vert D)</math> (i.e., <math>\ln{p(S\vert D)\over p(\neg S\vert D)} > 0</math>), otherwise it is not spam.
 
== See also ==
* [[AODE]]
* [[Bayesian spam filtering]]
* [[Bayesian network]]
* [[Random naive Bayes]]
* [[Linear classifier]]
* [[Bayesian inference]] (esp. as Bayesian techniques relate to [[Spam (e-mail)|spam]])
* [[Boosting (meta-algorithm)]]
* [[Fuzzy logic]]
* [[Logistic regression]]
* [[Class membership probabilities]]
* [[Neural network]]s
* [[Predictive analytics]]
* [[Perceptron]]
* [[Support vector machine]]
* [[Feature selection]]
 
==References==
{{More footnotes|date=May 2009}}
{{reflist}}
 
===Further reading===
* Domingos, Pedro & Michael Pazzani (1997) "On the optimality of the simple Bayesian classifier under zero-one loss". ''Machine Learning'', 29:103–137. ''(also online at [http://citeseer.ist.psu.edu/ CiteSeer]: [http://citeseer.ist.psu.edu/domingos97optimality.html])''
* Rish, Irina. (2001). "An empirical study of the naive Bayes classifier". IJCAI 2001 Workshop on Empirical Methods in Artificial Intelligence. ''(available online: [http://www.research.ibm.com/people/r/rish/papers/RC22230.pdf PDF], [http://www.research.ibm.com/people/r/rish/papers/ijcai-ws.ps PostScript])''
* Hand, DJ, & Yu, K. (2001). "Idiot's Bayes - not so stupid after all?" International Statistical Review.  Vol 69 part 3, pages 385-399. ISSN 0306-7734.
* Webb, G. I., J. Boughton, and Z. Wang (2005). [http://www.springerlink.com/content/u8w306673m1p866k/ Not So Naive Bayes: Aggregating One-Dependence Estimators]. Machine Learning 58(1). Netherlands: Springer, pages 5–24.
* Mozina M, Demsar J, Kattan M, & Zupan B. (2004). "Nomograms for Visualization of Naive Bayesian Classifier". In Proc. of PKDD-2004, pages 337-348. ''(available online: [http://www.ailab.si/blaz/papers/2004-PKDD.pdf PDF])''
* Maron, M. E. (1961). "Automatic Indexing: An Experimental Inquiry." Journal of the ACM (JACM) 8(3):404–417. ''(available online: [http://delivery.acm.org/10.1145/330000/321084/p404-maron.pdf?key1=321084&key2=9636178211&coll=GUIDE&dl=ACM&CFID=56729577&CFTOKEN=37855803 PDF])''
* Minsky, M. (1961). "Steps toward Artificial Intelligence." Proceedings of the IRE 49(1):8-30.
* McCallum, A. and Nigam K.  "A Comparison of Event Models for Naive Bayes Text Classification".  In AAAI/ICML-98 Workshop on Learning for Text Categorization, pp.&nbsp;41–48. Technical Report WS-98-05. AAAI Press. 1998.  ''(available online: [http://www.kamalnigam.com/papers/multinomial-aaaiws98.pdf PDF])''
* Rennie J, Shih L, Teevan J, and Karger D.  Tackling The Poor Assumptions of Naive Bayes Classifiers.  In Proceedings of the Twentieth International Conference on Machine Learning (ICML). 2003. ''(available online: [http://people.csail.mit.edu/~jrennie/papers/icml03-nb.pdf PDF])''
 
==External links==
* [http://nlp.stanford.edu/IR-book/html/htmledition/naive-bayes-text-classification-1.html Book Chapter: Naive Bayes text classification, Introduction to Information Retrieval]
* [http://www.cs.waikato.ac.nz/~eibe/pubs/FrankAndBouckaertPKDD06new.pdf Naive Bayes for Text Classification with Unbalanced Classes]
* [http://tunedit.org/results?d=UCI/&a=bayes Benchmark results of Naive Bayes implementations]
* [http://www.biomedcentral.com/1471-2105/7/514 Hierarchical Naive Bayes Classifiers for uncertain data] (an extension of the Naive Bayes classifier).
* [http://www.lwebzem.com/cgi-bin/res/naive_bayes_tm_classifier.cgi Document Classification Using Naive Bayes Classifier with Perl]
;Software
* Naive Bayes classifiers are available in many general-purpose machine learning and NLP packages, including [[Apache Mahout]], [http://mallet.cs.umass.edu/ Mallet], [[NLTK]], [[Orange (software)|Orange]], [[scikit-learn]] and [[Weka (machine learning)|Weka]].
* [[IMSL Numerical Libraries]] Collections of math and statistical algorithms available in C/C++, Fortran, Java and C#/.NET. Data mining routines in the IMSL Libraries include a Naive Bayes classifier.
* [http://doc.winnowtag.org/open-source Winnow content recommendation] Open source Naive Bayes text classifier works with very small training and unbalanced training sets. High performance, C, any Unix.
* An interactive [[Microsoft Excel]] spreadsheet [http://downloads.sourceforge.net/naivebayesclass/NaiveBayesDemo.xls?use_mirror=osdn Naive Bayes implementation] using [[Visual Basic for Applications|VBA]] (requires enabled macros) with viewable source code.
* [http://jbnc.sourceforge.net/ jBNC - Bayesian Network Classifier Toolbox]
* [http://cmp.felk.cvut.cz/cmp/software/stprtool/ Statistical Pattern Recognition Toolbox for Matlab].
* [http://people.csail.mit.edu/jrennie/ifile/ ifile] - the first freely available (Naive) Bayesian mail/spam filter
* [http://nclassifier.sourceforge.net/ NClassifier] - NClassifier is a .NET library that supports text classification and text summarization. It is a port of Classifier4J.
* [http://classifier4j.sourceforge.net/ Classifier4J] - Classifier4J is a Java library designed to do text classification. It comes with an implementation of a Bayesian classifier.
 
[[Category:Classification algorithms]]
[[Category:Bayesian statistics]]
[[Category:Statistical classification]]

Revision as of 03:21, 10 November 2013

Template:Multiple issues

Genital herpes is a kind of sexually transmitted disease that certain becomes through sexual or oral connection with someone else that is afflicted by the viral disorder. Oral herpes requires occasional eruptions of fever blisters" round the mouth Figure 02 Also known as cold sores" or fever blisters," characteristic herpes lesions often appear around the mouth sometimes of illness, after sunlight or wind publicity, during menstruation, or with mental stress.

Though statistical numbers aren't nearly where they should be, increasing numbers of people are arriving at various clinics regarding the herpes symptoms also to have themselves and their companions treated.

Because symptoms may be recognised incorrectly as skin irritation or something else, a partner can't be determined by the partner with herpes to constantly find out when he or she is contagious. Some who contract herpes are symptom-no cost, others have just one breakout, and still others have standard bouts of symptoms.

Similarly, careful hand washing should be practiced to avoid the virus from spreading to other parts of the body, especially the eye and mouth. If you think you have already been exposed or show signs of herpes infection, see your medical provider. Prompt qualified diagnosis may boost your chances of responding to a prescription drugs like acyclovir that decreases the duration and severity of a short bout of symptoms.

HSV type 1 is the herpes virus that is usually responsible for cold sores of the mouth, the so-referred to as " fever blisters." You get HSV-1 by coming into contact with the saliva of an contaminated person.

If you are you looking for more information regarding herpes symptoms oral pictures look into our own web page. A naive Bayes classifier is a simple probabilistic classifier based on applying Bayes' theorem with strong (naive) independence assumptions. A more descriptive term for the underlying probability model would be "independent feature model". An overview of statistical classifiers is given in the article on Pattern recognition.

Introduction

In simple terms, a naive Bayes classifier assumes that the presence or absence of a particular feature is unrelated to the presence or absence of any other feature, given the class variable. For example, a fruit may be considered to be an apple if it is red, round, and about 3" in diameter. A naive Bayes classifier considers each of these features to contribute independently to the probability that this fruit is an apple, regardless of the presence or absence of the other features.

For some types of probability models, naive Bayes classifiers can be trained very efficiently in a supervised learning setting. In many practical applications, parameter estimation for naive Bayes models uses the method of maximum likelihood; in other words, one can work with the naive Bayes model without accepting Bayesian probability or using any Bayesian methods.

Despite their naive design and apparently oversimplified assumptions, naive Bayes classifiers have worked quite well in many complex real-world situations. In 2004, an analysis of the Bayesian classification problem showed that there are sound theoretical reasons for the apparently implausible efficacy of naive Bayes classifiers.[1] Still, a comprehensive comparison with other classification algorithms in 2006 showed that Bayes classification is outperformed by other approaches, such as boosted trees or random forests.[2]

An advantage of Naive Bayes is that it only requires a small amount of training data to estimate the parameters (means and variances of the variables) necessary for classification. Because independent variables are assumed, only the variances of the variables for each class need to be determined and not the entire covariance matrix.

Probabilistic model

Abstractly, the probability model for a classifier is a conditional model.

p(C|F1,,Fn)

over a dependent class variable C with a small number of outcomes or classes, conditional on several feature variables F1 through Fn. The problem is that if the number of features n is large or when a feature can take on a large number of values, then basing such a model on probability tables is infeasible. We therefore reformulate the model to make it more tractable.

Using Bayes' theorem, this can be written

p(C|F1,,Fn)=p(C)p(F1,,Fn|C)p(F1,,Fn).

In plain English the above equation can be written as

posterior=prior×likelihoodevidence.

In practice, there is interest only in the numerator of that fraction, because the denominator does not depend on C and the values of the features Fi are given, so that the denominator is effectively constant. The numerator is equivalent to the joint probability model

p(C,F1,,Fn)

which can be rewritten as follows, using the chain rule for repeated applications of the definition of conditional probability:

p(C,F1,,Fn)
=p(C)p(F1,,Fn|C)
=p(C)p(F1|C)p(F2,,Fn|C,F1)
=p(C)p(F1|C)p(F2|C,F1)p(F3,,Fn|C,F1,F2)
=p(C)p(F1|C)p(F2|C,F1)p(F3|C,F1,F2)p(F4,,Fn|C,F1,F2,F3)
=p(C)p(F1|C)p(F2|C,F1)p(Fn|C,F1,F2,F3,,Fn1).

Now the "naive" conditional independence assumptions come into play: assume that each feature Fi is conditionally independent of every other feature Fj for ji given the category C. This means that

p(Fi|C,Fj)=p(Fi|C), p(Fi|C,Fj,Fk)=p(Fi|C) , p(Fi|C,Fj,Fk,Fl)=p(Fi|C), and so on,

for ij,k,l, and so the joint model can be expressed as

p(C|F1,,Fn)p(C,F1,,Fn)p(C)p(F1|C)p(F2|C)p(F3|C)p(C)i=1np(Fi|C).

This means that under the above independence assumptions, the conditional distribution over the class variable C is:

p(C|F1,,Fn)=1Zp(C)i=1np(Fi|C)

where Z (the evidence) is a scaling factor dependent only on F1,,Fn, that is, a constant if the values of the feature variables are known.

Models of this form are much more manageable, because they factor into a so-called class prior p(C) and independent probability distributions p(Fi|C). If there are k classes and if a model for each p(Fi|C=c) can be expressed in terms of r parameters, then the corresponding naive Bayes model has (k − 1) + n r k parameters. In practice, often k=2 (binary classification) and r=1 (Bernoulli variables as features) are common, and so the total number of parameters of the naive Bayes model is 2n+1, where n is the number of binary features used for classification.

Parameter estimation and event models

All model parameters (i.e., class priors and feature probability distributions) can be approximated with relative frequencies from the training set. These are maximum likelihood estimates of the probabilities. A class' prior may be calculated by assuming equiprobable classes (i.e., priors = 1 / (number of classes)), or by calculating an estimate for the class probability from the training set (i.e., (prior for a given class) = (number of samples in the class) / (total number of samples)). To estimate the parameters for a feature's distribution, one must assume a distribution or generate nonparametric models for the features from the training set.[3]

The assumptions on distributions of features are called the event model of the Naive Bayes classifier. For discrete features like the ones encountered in document classification (include spam filtering), multinomial and Bernoulli distributions are popular. These assumptions lead to two distinct models, which are often confused.[4][5] When dealing with continuous data, a typical assumption is that the continuous values associated with each class are distributed according to a Gaussian distribution.

For example, suppose the training data contain a continuous attribute, x. We first segment the data by the class, and then compute the mean and variance of x in each class. Let μc be the mean of the values in x associated with class c, and let σc2 be the variance of the values in x associated with class c. Then, the probability density of some value given a class, P(x=v|c), can be computed by plugging v into the equation for a Normal distribution parameterized by μc and σc2. That is,

P(x=v|c)=12πσc2e(vμc)22σc2

Another common technique for handling continuous values is to use binning to discretize the feature values, to obtain a new set of Bernoulli-distributed features. In general, the distribution method is a better choice if there is a small amount of training data, or if the precise distribution of the data is known. The discretization method tends to do better if there is a large amount of training data because it will learn to fit the distribution of the data. Since naive Bayes is typically used when a large amount of data is available (as more computationally expensive models can generally achieve better accuracy), the discretization method is generally preferred over the distribution method.

Sample correction

If a given class and feature value never occur together in the training data, then the frequency-based probability estimate will be zero. This is problematic because it will wipe out all information in the other probabilities when they are multiplied. Therefore, it is often desirable to incorporate a small-sample correction, called pseudocount, in all probability estimates such that no probability is ever set to be exactly zero.

Constructing a classifier from the probability model

The discussion so far has derived the independent feature model, that is, the naive Bayes probability model. The naive Bayes classifier combines this model with a decision rule. One common rule is to pick the hypothesis that is most probable; this is known as the maximum a posteriori or MAP decision rule. The corresponding classifier, a Bayes classifier, is the function classify defined as follows:

classify(f1,,fn)=argmaxcp(C=c)i=1np(Fi=fi|C=c).

Discussion

Despite the fact that the far-reaching independence assumptions are often inaccurate, the naive Bayes classifier has several properties that make it surprisingly useful in practice. In particular, the decoupling of the class conditional feature distributions means that each distribution can be independently estimated as a one dimensional distribution. This helps alleviate problems stemming from the curse of dimensionality, such as the need for data sets that scale exponentially with the number of features.[6] While naive Bayes often fails to produce a good estimate for the correct class probabilities, this may not be a requirement for many applications. For example, the naive Bayes classifier will make the correct MAP decision rule classification so long as the correct class is more probable than any other class. This is true regardless of whether the probability estimate is slightly, or even grossly inaccurate. In this manner, the overall classifier can be robust enough to ignore serious deficiencies in its underlying naive probability model. Other reasons for the observed success of the naive Bayes classifier are discussed in the literature cited below.

Examples

Sex classification

Problem: classify whether a given person is a male or a female based on the measured features. The features include height, weight, and foot size.

Training

Example training set below.

sex height (feet) weight (lbs) foot size(inches)
male 6 180 12
male 5.92 (5'11") 190 11
male 5.58 (5'7") 170 12
male 5.92 (5'11") 165 10
female 5 100 6
female 5.5 (5'6") 150 8
female 5.42 (5'5") 130 7
female 5.75 (5'9") 150 9

The classifier created from the training set using a Gaussian distribution assumption would be (given variances are sample variances):

sex mean (height) variance (height) mean (weight) variance (weight) mean (foot size) variance (foot size)
male 5.855 3.5033e-02 176.25 1.2292e+02 11.25 9.1667e-01
female 5.4175 9.7225e-02 132.5 5.5833e+02 7.5 1.6667e+00

Let's say we have equiprobable classes so P(male)= P(female) = 0.5. This prior probability distribution might be based on our knowledge of frequencies in the larger population, or on frequency in the training set.

Testing

Below is a sample to be classified as a male or female.

sex height (feet) weight (lbs) foot size(inches)
sample 6 130 8

We wish to determine which posterior is greater, male or female. For the classification as male the posterior is given by

posterior(male)=P(male)p(height|male)p(weight|male)p(footsize|male)evidence

For the classification as female the posterior is given by

posterior(female)=P(female)p(height|female)p(weight|female)p(footsize|female)evidence

The evidence (also termed normalizing constant) may be calculated:

evidence=P(male)p(height|male)p(weight|male)p(footsize|male)
+P(female)p(height|female)p(weight|female)p(footsize|female)

However, given the sample the evidence is a constant and thus scales both posteriors equally. It therefore does not affect classification and can be ignored. We now determine the probability distribution for the sex of the sample.

P(male)=0.5
p(height|male)=12πσ2exp((6μ)22σ2)1.5789,

where μ=5.855 and σ2=3.5033e02 are the parameters of normal distribution which have been previously determined from the training set. Note that a value greater than 1 is OK here – it is a probability density rather than a probability, because height is a continuous variable.

p(weight|male)=5.9881e06
p(foot size|male)=1.3112e3
posterior numerator (male)=their product=6.1984e09
P(female)=0.5
p(height|female)=2.2346e1
p(weight|female)=1.6789e2
p(foot size|female)=2.8669e1
posterior numerator (female)=their product=5.3778e04

Since posterior numerator is greater in the female case, we predict the sample is female.

Document Classification

Here is a worked example of naive Bayesian classification to the document classification problem. Consider the problem of classifying documents by their content, for example into spam and non-spam e-mails. Imagine that documents are drawn from a number of classes of documents which can be modelled as sets of words where the (independent) probability that the i-th word of a given document occurs in a document from class C can be written as

p(wi|C)

(For this treatment, we simplify things further by assuming that words are randomly distributed in the document - that is, words are not dependent on the length of the document, position within the document with relation to other words, or other document-context.)

Then the probability that a given document D contains all of the words wi, given a class C, is

p(D|C)=ip(wi|C)

The question that we desire to answer is: "what is the probability that a given document D belongs to a given class C?" In other words, what is p(C|D)?

Now by definition

p(D|C)=p(DC)p(C)

and

p(C|D)=p(DC)p(D)

Bayes' theorem manipulates these into a statement of probability in terms of likelihood.

p(C|D)=p(C)p(D)p(D|C)

Assume for the moment that there are only two mutually exclusive classes, S and ¬S (e.g. spam and not spam), such that every element (email) is in either one or the other;

p(D|S)=ip(wi|S)

and

p(D|¬S)=ip(wi|¬S)

Using the Bayesian result above, we can write:

p(S|D)=p(S)p(D)ip(wi|S)
p(¬S|D)=p(¬S)p(D)ip(wi|¬S)

Dividing one by the other gives:

p(S|D)p(¬S|D)=p(S)ip(wi|S)p(¬S)ip(wi|¬S)

Which can be re-factored as:

p(S|D)p(¬S|D)=p(S)p(¬S)ip(wi|S)p(wi|¬S)

Thus, the probability ratio p(S | D) / p(¬S | D) can be expressed in terms of a series of likelihood ratios. The actual probability p(S | D) can be easily computed from log (p(S | D) / p(¬S | D)) based on the observation that p(S | D) + p(¬S | D) = 1.

Taking the logarithm of all these ratios, we have:

lnp(S|D)p(¬S|D)=lnp(S)p(¬S)+ilnp(wi|S)p(wi|¬S)

(This technique of "log-likelihood ratios" is a common technique in statistics. In the case of two mutually exclusive alternatives (such as this example), the conversion of a log-likelihood ratio to a probability takes the form of a sigmoid curve: see logit for details.)

Finally, the document can be classified as follows. It is spam if p(S|D)>p(¬S|D) (i.e., lnp(S|D)p(¬S|D)>0), otherwise it is not spam.

See also

References

Template:More footnotes 43 year old Petroleum Engineer Harry from Deep River, usually spends time with hobbies and interests like renting movies, property developers in singapore new condominium and vehicle racing. Constantly enjoys going to destinations like Camino Real de Tierra Adentro.

Further reading

  • Domingos, Pedro & Michael Pazzani (1997) "On the optimality of the simple Bayesian classifier under zero-one loss". Machine Learning, 29:103–137. (also online at CiteSeer: [1])
  • Rish, Irina. (2001). "An empirical study of the naive Bayes classifier". IJCAI 2001 Workshop on Empirical Methods in Artificial Intelligence. (available online: PDF, PostScript)
  • Hand, DJ, & Yu, K. (2001). "Idiot's Bayes - not so stupid after all?" International Statistical Review. Vol 69 part 3, pages 385-399. ISSN 0306-7734.
  • Webb, G. I., J. Boughton, and Z. Wang (2005). Not So Naive Bayes: Aggregating One-Dependence Estimators. Machine Learning 58(1). Netherlands: Springer, pages 5–24.
  • Mozina M, Demsar J, Kattan M, & Zupan B. (2004). "Nomograms for Visualization of Naive Bayesian Classifier". In Proc. of PKDD-2004, pages 337-348. (available online: PDF)
  • Maron, M. E. (1961). "Automatic Indexing: An Experimental Inquiry." Journal of the ACM (JACM) 8(3):404–417. (available online: PDF)
  • Minsky, M. (1961). "Steps toward Artificial Intelligence." Proceedings of the IRE 49(1):8-30.
  • McCallum, A. and Nigam K. "A Comparison of Event Models for Naive Bayes Text Classification". In AAAI/ICML-98 Workshop on Learning for Text Categorization, pp. 41–48. Technical Report WS-98-05. AAAI Press. 1998. (available online: PDF)
  • Rennie J, Shih L, Teevan J, and Karger D. Tackling The Poor Assumptions of Naive Bayes Classifiers. In Proceedings of the Twentieth International Conference on Machine Learning (ICML). 2003. (available online: PDF)

External links

Software
  1. 55 years old Systems Administrator Antony from Clarence Creek, really loves learning, PC Software and aerobics. Likes to travel and was inspired after making a journey to Historic Ensemble of the Potala Palace.

    You can view that web-site... ccleaner free download
  2. 55 years old Systems Administrator Antony from Clarence Creek, really loves learning, PC Software and aerobics. Likes to travel and was inspired after making a journey to Historic Ensemble of the Potala Palace.

    You can view that web-site... ccleaner free download
  3. George H. John and Pat Langley (1995). Estimating Continuous Distributions in Bayesian Classifiers. Proceedings of the Eleventh Conference on Uncertainty in Artificial Intelligence. pp. 338-345. Morgan Kaufmann, San Mateo.
  4. McCallum, Andrew, and Kamal Nigam. "A comparison of event models for Naive Bayes text classification." AAAI-98 workshop on learning for text categorization. Vol. 752. 1998.
  5. Metsis, Vangelis, Ion Androutsopoulos, and Georgios Paliouras. "Spam filtering with Naive Bayes—which Naive Bayes?" Third conference on email and anti-spam (CEAS). Vol. 17. 2006.
  6. An introductory tutorial to classifiers (introducing the basic terms, with numeric example)