how to calculate training accuracy in python