详细参考代码

  1. from sklearn import svm
  2. from sklearn import datasets
  3. from sklearn.externals import joblib
  4. ### 各种计算,这里仅是例子
  5. clf = svm.SVC()
  6. iris = datasets.load_iris()
  7. X, y = iris.data, iris.target
  8. clf.fit(X, y)
  9. ### 保存到硬盘,此时Saved_model001.pkl,并且读取(调用Sample已提供)
  10. joblib.dump(clf, 'Saved_model001.pkl')
  11. clf2 = joblib.load('Saved_model001.pkl')
  12. print(clf2.predict(X[0:1]))

参考资料