【发布时间】:2021-02-06 13:07:21
【问题描述】:
我的代码是朴素贝叶斯分类器,我想计算正面和负面的句子
pos_count=0
neg_count=0
file = open("a-samples.txt","r")
for line in file:
custom_tokens = remove_noise(word_tokenize(line))
print('\n',line,'\n',classifier.classify(dict([token, True] for token in custom_tokens)))
if (classifier.classify(dict([token, True] for token in custom_tokens) = "Positive"
pos_count=pos_count+1
elif (classifier.classify(dict([token, True] for token in custom_tokens)="Negative"
neg_count=neg_count+1
print ("pos =",pos_count,'\n',"neg= ",neg_count)
【问题讨论】:
-
请用您的问题发布整个回溯。这将帮助其他人查明您代码中的问题
标签: python classification naivebayes