TrainingSet/TestSet and generalized i/o functions