def evaluate_svm(test_data, train_data, classifier, logfile=None):
    """
    Evaluates svm, writes output to logfile in tsv format with columns:
    - svm description
    - accuracy on test set
    - accuracy on train set

    """
    train_x, train_y = train_data
    classifier.fit(train_x, train_y)

    test_x, test_y = test_data

    train_accuracy = classifier.score(train_x, train_y)
    test_accuracy = classifier.score(test_x, test_y)

    out_msg = '\t'.join((str(classifier.C), str(classifier.kernel), str(test_accuracy), str(train_accuracy)))
    print(out_msg)

    if logfile is not None:
        with open(logfile, 'a+') as lf:
            lf.writelines([out_msg])

    return test_accuracy, train_accuracy