Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two fixes in NaiveBayesClassifier #224

Merged
merged 1 commit into from Feb 18, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions nltk/classify/naivebayes.py
Expand Up @@ -34,7 +34,7 @@


from collections import defaultdict from collections import defaultdict


from nltk.probability import FreqDist, DictionaryProbDist, ELEProbDist, sum_logs from nltk.probability import FreqDist, ConditionalFreqDist, DictionaryProbDist, ELEProbDist, sum_logs


from api import ClassifierI from api import ClassifierI


Expand Down Expand Up @@ -94,7 +94,7 @@ def prob_classify(self, featureset):
# Otherwise, we'll just assign a probability of 0 to # Otherwise, we'll just assign a probability of 0 to
# everything. # everything.
featureset = featureset.copy() featureset = featureset.copy()
for fname in featureset: for fname in featureset.keys():
for label in self._labels: for label in self._labels:
if (label, fname) in self._feature_probdist: if (label, fname) in self._feature_probdist:
break break
Expand Down Expand Up @@ -184,7 +184,7 @@ def train(labeled_featuresets, estimator=ELEProbDist):
i.e., a list of tuples ``(featureset, label)``. i.e., a list of tuples ``(featureset, label)``.
""" """
label_freqdist = FreqDist() label_freqdist = FreqDist()
feature_freqdist = defaultdict(FreqDist) feature_freqdist = ConditionalFreqDist()
feature_values = defaultdict(set) feature_values = defaultdict(set)
fnames = set() fnames = set()


Expand Down