Using LSTMs for supervised text classification
In this recipe, we will build a deep learning LSTM classifier for the BBC News dataset. There is not enough data to build a great classifier, but we will use the same dataset for comparison. By the end of this recipe, you will have a complete LSTM classifier that is trained and can be tested on new inputs.
Getting ready
In order to build the recipe, we need to install tensorflow
and keras
:
pip install tensorflow pip install keras
In this recipe, we will use the same BBC dataset to create an LSTM classification model.
How to do it…
The general structure of the training is similar to plain machine learning model training, where we clean the data, create the dataset, and split it into training and testing datasets. We then train a model and test it on unseen data. The particulars of the training are different for deep learning as opposed to statistical machine learning, such as SVMs. The steps for this recipe are...