sklearn库中GridSearchCV方法打包为exe方法后报错:joblib.externals.loky.process_executor.TerminatedWorkerError

sklearn库中GridSearchCV方法打包为exe方法后报错:joblib.externals.loky.process_executor.TerminatedWorkerError

将sklearn库中GridSearchCV方法,使用pyinstaller打包为exe方法后报错:joblib.externals.loky.process_executor.TerminatedWorkerError: A worker process managed by the executor was unexpectedly terminated. This could be caused by a segmentation fault while calling the function or by an excessive memory usage causing the Operating System to kill the worker.

查询了诸多方法,可能是系统线程和进程的一些区别导致的问题。
在这里插入图片描述
最后在github上找到答案,主要是joblib库的一些bug
https://github.com/joblib/joblib/issues/1002
在这里插入图片描述
简单来说,

joblib.externals.loky.process_executor._RemoteTraceback: """ Traceback (most recent call last): File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\joblib\externals\loky\process_executor.py", line 490, in _process_worker r = call_item() ^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\joblib\externals\loky\process_executor.py", line 291, in __call__ return self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\joblib\parallel.py", line 606, in __call__ return [func(*args, **kwargs) for func, args, kwargs in self.items] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\joblib\parallel.py", line 606, in <listcomp> return [func(*args, **kwargs) for func, args, kwargs in self.items] ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\utils\parallel.py", line 139, in __call__ return self.function(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\model_selection\_validation.py", line 866, in _fit_and_score estimator.fit(X_train, y_train, **fit_params) File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\base.py", line 1382, in wrapper estimator._validate_params() File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\base.py", line 436, in _validate_params validate_parameter_constraints( File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\utils\_param_validation.py", line 98, in validate_parameter_constraints raise InvalidParameterError( sklearn.utils._param_validation.InvalidParameterError: The 'criterion' parameter of RandomForestRegressor must be a str among {'poisson', 'friedman_mse', 'squared_error', 'absolute_error'}. Got 'mae' instead. """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "D:\python\电力负荷预测.py", line 69, in <module> random_search.fit(X_train, y_train) File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\base.py", line 1389, in wrapper return fit_method(estimator, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\model_selection\_search.py", line 1024, in fit self._run_search(evaluate_candidates) File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\model_selection\_search.py", line 1951, in _run_search evaluate_candidates( File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\model_selection\_search.py", line 970, in evaluate_candidates out = parallel( ^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\utils\parallel.py", line 77, in __call__ return super().__call__(iterable_with_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\joblib\parallel.py", line 2071, in __call__ return output if self.return_generator else list(output) ^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\joblib\parallel.py", line 1681, in _get_outputs yield from self._retrieve() File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\joblib\parallel.py", line 1783, in _retrieve self._raise_error_fast() File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\joblib\parallel.py", line 1858, in _raise_error_fast error_job.get_result(self.timeout) File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\joblib\parallel.py", line 757, in get_result return self._return_or_raise() ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\joblib\parallel.py", line 772, in _return_or_raise raise self._result sklearn.utils._param_validation.InvalidParameterError: The 'criterion' parameter of RandomForestRegressor must be a str among {'poisson', 'friedman_mse', 'squared_error', 'absolute_error'}. Got 'mae' instead.
最新发布
05-15
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值