Defining the train and evaluate functions