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
interchangeably in this recipe.
Getting ready
To use the
SklearnClassifier
class, you must have scikit-learn
installed. Instructions are available online at http://scikit-learn.org/stable/install.html. If you have all the dependencies installed, such...