背景
在做硕士毕业设计的时候,用到随机森林这个模型,在写完代码的时候,跑的时候,老是出现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