Using SVMs for sentiment mining
We have now seen how SVMs provide classifiers by finding hyperplanes that separate the data into classes and have seen a graphical explanation of how such hyperplanes can be found, even when the data is not linearly separable. Now, we’ll look at how SVMs can be applied to our datasets to find the boundaries between sentiments, with an analysis of their behavior on single-label and multi-label datasets and a preliminary investigation into how their performance on multi-label datasets might be improved.
Applying our SVMs
As with the previous classifiers, we can define the SVMCLASSIFIERs
class as a subclass of SKLEARNCLASSIFIER
by using the following initialization code (useDF
is a flag to decide whether to use the TF-IDF algorithm from Chapter 5, Sentiment Lexicons and Vector Space Models when building the training set; max_iter
sets an upper bound on the number of iterations the SVM algorithm should carry out – for our examples, the...