def get_optimal_polarity_classifier(): """ Trains and returns the optimal polarity classifier. """ tweets = utils.get_pickles(3) tweets, targets = utils.make_polarity_targets(tweets) vect_options = { 'ngram_range': (1,1), 'max_df': 0.5 } tfidf_options = { 'sublinear_tf': False, 'use_idf': True, 'smooth_idf': True, } clf = SVM(tweets, targets, vect_options, tfidf_options) clf.set_feature_set('PC2', features.get_google_sentiment_values(3)) clf.train_on_feature_set() return clf