Training and test set preparation