在随机森林调参中(用的jupyter lab),出现了错误,以下是代码
scorel = []
for i in range(0,200,20):
rfc = RandomForestClassifier(n_estimators=i+1,
n_jobs=-1,
random_state=90)
score = cross_val_score(rfc,data.data,data.target,cv=10).mean()
scorel.append(score)
print(max(scorel),(scorel.index(max(scorel))*10)+1)
plt.figure(figsize=[20,5])
plt.plot(range(1,201,10),scorel)
plt.show()
提示错误:
D:\Anaconda3\lib\site-packages\sklearn\model_selection\_validation.py:372: FitFailedWarning:
10 fits failed out of a total of 10.
The score on these train-test partitions for these parameters will be set to nan.
If these failures are not expected, you can try to debug them by setting error_score='raise'.
Below are more details about the failures:
--------------------------------------------------------------------------------
10 fits failed with the following error:
Traceback (most recent call last):
File "D:\Anaconda3\lib\site-packages\sklearn\model_selection\_validation.py", line 680, in _fit_and_score
estimator.fit(X_train, y_train, **fit_params)
File "D:\Anaconda3\lib\site-packages\sklearn\ensemble\_forest.py", line 450, in fit
trees = Parallel(
File "D:\Anaconda3\lib\site-packages\joblib\parallel.py", line 968, in __call__
n_jobs = self._initialize_backend()
File "D:\Anaconda3\lib\site-packages\joblib\parallel.py", line 735, in _initialize_backend
n_jobs = self._backend.configure(n_jobs=self.n_jobs, parallel=self,
File "D:\Anaconda3\lib\site-packages\joblib\_parallel_backends.py", line 494, in configure
self._workers = get_memmapping_executor(
File "D:\Anaconda3\lib\site-packages\joblib\executor.py", line 20, in get_memmapping_executor
return MemmappingExecutor.get_memmapping_executor(n_jobs, **kwargs)
File "D:\Anaconda3\lib\site-packages\joblib\executor.py", line 42, in get_memmapping_executor
manager = TemporaryResourcesManager(temp_folder)
File "D:\Anaconda3\lib\site-packages\joblib\_memmapping_reducer.py", line 531, in __init__
self.set_current_context(context_id)
File "D:\Anaconda3\lib\site-packages\joblib\_memmapping_reducer.py", line 535, in set_current_context
self.register_new_context(context_id)
File "D:\Anaconda3\lib\site-packages\joblib\_memmapping_reducer.py", line 560, in register_new_context
self.register_folder_finalizer(new_folder_path, context_id)
File "D:\Anaconda3\lib\site-packages\joblib\_memmapping_reducer.py", line 590, in register_folder_finalizer
resource_tracker.register(pool_subfolder, "folder")
File "D:\Anaconda3\lib\site-packages\joblib\externals\loky\backend\resource_tracker.py", line 191, in register
self._send('REGISTER', name, rtype)
File "D:\Anaconda3\lib\site-packages\joblib\externals\loky\backend\resource_tracker.py", line 204, in _send
msg = '{0}:{1}:{2}\n'.format(cmd, name, rtype).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-20: ordinal not in range(128)
warnings.warn(some_fits_failed_message, FitFailedWarning)
D:\Anaconda3\lib\site-packages\sklearn\model_selection\_validation.py:372: FitFailedWarning:
10 fits failed out of a total of 10.
The score on these train-test partitions for these parameters will be set to nan.
If these failures are not expected, you can try to debug them by setting error_score='raise'.
Below are more details about the failures:
这个是哪里的问题,该怎么解决