mirror of
https://gitee.com/TheAlgorithms/Statistical-Learning-Method_Code.git
synced 2024-12-22 12:48:55 +08:00
Update NaiveBayes.py
support for python >=3.6
This commit is contained in:
parent
02a3ae6f31
commit
b7f249fe31
@ -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)
|
||||
print('time span:', time.time() -start)
|
||||
|
Loading…
Reference in New Issue
Block a user