我按如下方式保存了一个模型对象:
with open('bestModel_smv_3class_version2data.pickle','wb') as f:
pickle.dump(jpsa_svm_3class.g_cv.best_estimator_,f)
现在当我尝试加载它时,它会出错
with open('bestModel_smv_3class_version2data.pickle','rb') as f:
svm_bestModel=pickle.load(f)
错误:
EOFError Traceback (most recent call last)
<ipython-input-66-df8734c64828> in <module>()
8
9 with open('bestModel_smv_3class_version2data.pickle','rb') as f:
---> 10 svm_bestModel=pickle.load(f)
EOFError: Ran out of input
答案 0 :(得分:0)
pickle
无法处理sklearn
个模型,因为它们包含numpy
个数组。使用joblib.dump
代替它,但它们是特殊的,可以保存/加载大型numpy
数组。