Using SVMs for supervised text classification
In this recipe, we will build a machine learning classifier that uses the SVM algorithm. By the end of this recipe, you will have a working classifier that you will be able to test on new inputs and evaluate using the same classification_report
tools we used in the previous sections. We will use the same BBC news dataset we used with KMeans
previously.
Getting ready
We will continue working with the same packages that we already installed in the previous recipes. The packages needed are installed in the poetry
environment or by installing the requirements.txt
file.
The notebook is located at https://github.com/PacktPublishing/Python-Natural-Language-Processing-Cookbook-Second-Edition/blob/main/Chapter04/4.4-svm_classification.ipynb.
How to do it…
We will load the cleaned training and test data that we had saved in the previous recipe. We will then create the SVM classifier and train it. We will use BERT encoding as...