举例说明:
模型的保存过程:
from sklearn.externals import joblib
from sklearn import svm
import os
# os.chdir("workspace/model_save")
X = [[0, 0], [1, 1]]
y = [0, 1]
clf = svm.SVC()
clf.fit(X, y)
joblib.dump(clf, "train_model.m")
模型的读取过程:
from sklearn.externals import joblib
clf = joblib.load("train_model.m")
X = [[0, 0], [1, 1]]
y = [0, 1]
print(clf.predict(X))