Added in save if statment for learn.py and preallocated some arrays to speed up _generate_prediction()