Update NaiveBayes.py

support for python >=3.6
This commit is contained in:
Dod-o 2020-01-23 01:33:08 +08:00 committed by GitHub
parent 02a3ae6f31
commit b7f249fe31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,7 +73,7 @@ def NaiveBayes(Py, Px_y, x):
return P.index(max(P))
def test(Py, Px_y, testDataArr, testLabelArr):
def model_test(Py, Px_y, testDataArr, testLabelArr):
'''
对测试集进行测试
:param Py: 先验概率分布
@ -188,7 +188,7 @@ if __name__ == "__main__":
#使用习得的先验概率分布和条件概率分布对测试集进行测试
print('start to test')
accuracy = test(Py, Px_y, testDataArr, testLabelArr)
accuracy = model_test(Py, Px_y, testDataArr, testLabelArr)
#打印准确率
print('the accuracy is:', accuracy)