取消沉重的 python 对象返回错误:EOFError Ran out of input Python

发布于 2025-01-19 07:16:34 字数 598 浏览 4 评论 0原文

我已经制作了一种机器学习算法(RF),并将其保存为泡菜供进一步使用,文件为5GB。当我取消挑剔时,我会得到错误:

reg = pickle.load(f)
EOFError: Ran out of input

这就是我腌制回归的方式(来自Scikit-Learn)

#Pickle
pickle_out = open("D:\\data_for_learning\\Regression.pickle","wb")
pickle.dump(Reg, pickle_out)  #REG is from fit(x,y)
pickle_out.close()

,这就是它的挑战:

pickle_file = "D:\\data_for_learning\\RegressionRandom.pickle"
with open(pickle_file, 'rb') as f:
    reg = pickle.load(f)

我读到我可以意外地覆盖我的数据,但我只运行了一次,并试图尝试按照我写的方式取消挑选它。我可以再次重新运行机器学习部分,但我想知道问题的根源,为什么?我弄乱了腌制吗?

I have made a machine learning algorithm (RF) and saved it as a pickle for further use and the file is 5gb. When I unpickle it I get the error :

reg = pickle.load(f)
EOFError: Ran out of input

This is how I pickled the regression (from scikit-learn)

#Pickle
pickle_out = open("D:\\data_for_learning\\Regression.pickle","wb")
pickle.dump(Reg, pickle_out)  #REG is from fit(x,y)
pickle_out.close()

And this is how unpickle it:

pickle_file = "D:\\data_for_learning\\RegressionRandom.pickle"
with open(pickle_file, 'rb') as f:
    reg = pickle.load(f)

I have read that I could accidentally have overwritten my data but I have run it only once and tried to unpickle it the way I wrote it. I can rerun the machine learning part again but I want to know the source of the problem and why? Did I mess up the pickling?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文