Classifying documents with Support Vector Machines (SVMs)
SVMs are a popular and robust tool for text classification in applications such as intent recognition and chatbots. Unlike neural networks, which we will discuss in the next chapter, the training process is usually relatively quick and normally doesn’t require enormous amounts of data. That means that SVMs are good for applications that have to be quickly deployed, perhaps as a preliminary step in the development of a larger-scale application.
The basic idea behind SVMs is that if we represent documents as n-dimensional vectors (for example, the TF-IDF vectors that we discussed in Chapter 7, we want to be able to identify a hyperplane that provides a boundary that separates the documents into two categories with as large a boundary (or margin) as possible.
An illustration of using SVMs on the movie review data is shown here. We start, as usual, by importing the data and creating a train/test split:
import numpy...