added training with kNN and and a NaN check for objects in generate_training