O'Reilly logo

Python 3 Text Processing with NLTK 3 Cookbook by Jacob Perkins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Training scikit-learn classifiers

Scikit-learn is one of the best machine learning libraries available in any programming language. It contains all sorts of machine learning algorithms for many different purposes, but they all follow the same fit/predict design pattern:

  • Fit the model to the data
  • Use the model to make predictions

We won't be accessing the scikit-learn models directly in this recipe. Instead, we'll be using NLTK's SklearnClassifier class, which is a wrapper class around a scikit-learn model to make it conform to NLTK's ClassifierI interface. This means that the SklearnClassifier class can be trained and used much like the classifiers we've used in the previous recipes in this chapter.

Note

I may use the terms scikit-learn and sklearn ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required