train_classifier function