When doing model training, especially for cross validation on a training set, you typically want to save the model and then put it on a separate test set, which describes the save and reuse of the training model in Python.
Scikit-learn already has the model to persist the operation, the import joblib can
From sklearn.externals import Joblib
Model Save
>>> Os.chdir ("Workspace/model_save")
>>> from Sklearn import SVM
>>> X = [[0, 0], [1, 1]]
>>> y = [0, 1]
>>> CLF = SVM. SVC ()
>>> clf.fit (X, y)
>>> clf.fit (train_x,train_y)
>>> joblib.dump (CLF, " TRAIN_MODEL.M ")
The model can be saved locally by the Joblib dump, and the CLF is a trained classifier model to be recalled from the local
>>> CLF = joblib.load ("TRAIN_MODEL.M")
Load the saved model through the Joblib load method.
And then you can test it on the test set.
Clf.predit (test_x) #此处test_X为特征集