From b7f249fe3165ecab127066b30db983fa4e143698 Mon Sep 17 00:00:00 2001 From: Dod-o <45008728+Dod-o@users.noreply.github.com> Date: Thu, 23 Jan 2020 01:33:08 +0800 Subject: [PATCH] Update NaiveBayes.py support for python >=3.6 --- NaiveBayes/NaiveBayes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NaiveBayes/NaiveBayes.py b/NaiveBayes/NaiveBayes.py index 34e0b63..4d10d79 100644 --- a/NaiveBayes/NaiveBayes.py +++ b/NaiveBayes/NaiveBayes.py @@ -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,9 +188,9 @@ 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) #打印时间 - print('time span:', time.time() -start) \ No newline at end of file + print('time span:', time.time() -start)