作者:卢嘉颖链接:https://www.zhihu.com/question/27187105/answer/97334347来源:知乎著作权归作者所有,转载请联系作者获得授权。1. pickle>>> from sklearn import svm>>> from sklearn import datasets>>> clf = svm.SVC()>>> iris = datasets.load_iris()>>> X, y = iris.data, iris.target>>> clf.fit(X, y) SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, decision_function_shape=None, degree=3, gamma='auto', kernel='rbf', max_iter=-1, probability=False, random_state=None, shrinking=True, tol=0.001, verbose=False)>>> import pickle>>> s = pickle.dumps(clf)>>> clf2 = pickle.loads(s)>>> clf2.predict(X[0:1])array([0])>>> y[0]02. joblib>>> from sklearn.externals import joblib>>> joblib.dump(clf, 'filename.pkl') >>> clf = joblib.load('filename.pkl')