sklearn.externals.joblib.externals.loky.process_executor.BrokenProcessPool: A task has 未能取消序列化

在使用随机森林模型时,遇到`sklearn.externals.joblib.externals.loky.process_executor.BrokenProcessPool`错误,提示任务无法取消序列化。尝试降低sklearn版本和修改参数未解决问题,最终通过降低到sklearn 0.20.0并处理DeprecationWarning成功解决。该问题可能是由于函数参数不可序列化或版本不兼容导致。
摘要由CSDN通过智能技术生成

背景

在做硕士毕业设计的时候,用到随机森林这个模型,在写完代码的时候,跑的时候,老是出现sklearn.externals.joblib.externals.loky.process_executor.BrokenProcessPool: A task has failed to un-serialize. Please ensure that the arguments of the function are all picklable.翻译为中文是说:如果一个任务未能取消序列化,请确保函数的参数都是可解析的。

这个问题我是真没遇到过,结果,从晚上十点到十二点多,两个多小时,百度了好多,还去看了英文的一些解决方法,都不尽如意。后来,修改了参数,然后降低了sklearn版本后解决了,很是兴奋,所以,立马写下这个博客,希望后来者看到后能节约时间。

错误重现

 

重点是最后一句!!!
D:\myCode\PythonTest\MachineLearning\venv\lib\site-packages\sklearn\preprocessing\data.py:617: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.
  return self.partial_fit(X, y)
D:\myCode\PythonTest\MachineLearning\venv\lib\site-packages\sklearn\base.py:465: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.
  return self.fit(X, y, **fit_params).transform(X)
Fitting 3 folds for each of 9 candidates, totalling 27 fits
[Parallel(n_jobs=-1)]: Using backend LokyBackend with 8 concurrent workers.
exception calling callback for <Future at 0x16f80b6b748 state=finished raised BrokenProcessPool>
sklearn.externals.joblib.externals.loky.process_executor._RemoteTraceback: 
'''
Traceback (most recent call last):
  File "D:\myCode\PythonTest\MachineLearning\venv\lib\site-packages\sklearn\externals\joblib\externals\loky\process_executor.py", line 393, in _process_worker
    call_item = call_queue.get(block=True, timeout=timeout)
  File "C:\Program Files\Python37\lib\multiprocessing\queues.py", line 99, in get
    if not self._rlock.acquire(block, timeout):
PermissionError: [WinError 5] 拒绝访问。
'''
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "D:\myCode\PythonTest\MachineLearning\venv\lib\site-packages\sklearn\externals\joblib\externals\loky\_base.py", line 625, in _invoke_callbacks
    callback(self)
  File "D:\myCode\PythonTest\MachineLea

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小胡同1991

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值