Naive Bayes is a simple supervised learning method for text classification. Documents are classified based on the probability that a feature occurs in a class, (independent of other features).
(self, train=[], baseline=FREQUENCY, method=MULTINOMIAL, alpha=0.0001)
| 1968 | class NaiveBayes(Classifier): |
| 1969 | |
| 1970 | def __init__(self, train=[], baseline=FREQUENCY, method=MULTINOMIAL, alpha=0.0001): |
| 1971 | """ Naive Bayes is a simple supervised learning method for text classification. |
| 1972 | Documents are classified based on the probability that a feature occurs in a class, |
| 1973 | (independent of other features). |
| 1974 | """ |
| 1975 | self._classes = {} # {class: frequency} |
| 1976 | self._features = {} # {feature: frequency} |
| 1977 | self._likelihood = {} # {class: {feature: frequency}} |
| 1978 | self._method = method # MULTINOMIAL or BERNOUILLI. |
| 1979 | self._alpha = alpha # Smoothing. |
| 1980 | Classifier.__init__(self, train, baseline) |
| 1981 | |
| 1982 | @property |
| 1983 | def method(self): |