Preparing the training and test sets