Updated the traindata.py script

Fixed some errors and improved the output.