In this recipe, we're going to show how you can keep your model around for later use. For example, you might want to actually use a model to predict an outcome and automatically make a decision.
Persisting models with joblib or pickle
Getting ready
Create a dataset and train a classifier:
from sklearn.datasets import make_classification
from sklearn.tree import DecisionTreeClassifier
X, y = make_classification()
dt = DecisionTreeClassifier()
dt.fit(X, y)
How to do it...
- Save the training work the classifier has done with joblib:
from sklearn.externals import joblib
joblib...