我正在尝试使用RandomizedSearchCV为一个随机林调整超参数,但是在运行代码之后,我得到了一个PermissionError。你知道吗
最初的运行没有PermissionError(但是它确实抛出了一个无效的句柄错误),但是现在我根本无法运行代码。据我所知,当代码试图在没有适当权限的情况下格式化驱动器时,通常会抛出winerror5,但据我所知,RandomizedSearch并没有试图更改任何内容。我还没有尝试以管理员身份运行,但是访问该帐户将很困难,因此我正在尝试找出是否有其他方法来解决此问题。我正在运行python3.7。你知道吗
n_estimators = [int(x) for x in np.linspace(start=200, stop=2000, num=10)]
max_features = ['auto', 'sqrt']
max_depth = [int(x) for x in np.linspace(10, 110, num=11)]
max_depth.append(None)
min_samples_split = [2, 5, 10]
min_samples_leaf = [1, 2, 4]
bootstrap = [True, False]
random_grid = {'n_estimators': n_estimators,
'max_features': max_features,
'max_depth': max_depth,
'min_samples_split': min_samples_split,
'min_samples_leaf': min_samples_leaf,
'bootstrap': bootstrap}
print(random_grid)
constructed_data = pd.read_csv('Examples/Test_data.CSV')
forest = RandomForestClassifier()
forest.fit(train, train_labels)
forest_random = RandomizedSearchCV(estimator=forest, param_distributions=random_grid, n_iter=100,
cv=3, verbose=2, n_jobs=-1)
forest_random.fit(train, train_labels)
应为:无错误和建议的超参数值
实际值:
Fitting 3 folds for each of 100 candidates, totalling 300 fits
[Parallel(n_jobs=-1)]: Using backend LokyBackend with 4 concurrent workers.
exception calling callback for <Future at 0x1013bc90 state=finished raised BrokenProcessPool>
joblib.externals.loky.process_executor._RemoteTraceback:
'''
Traceback (most recent call last):
File "C:\Users\dalinar\PycharmProjects\visualizer\venv\lib\site-packages\joblib\externals\loky\process_executor.py", line 391, in _process_worker
call_item = call_queue.get(block=True, timeout=timeout)
File "C:\Users\dalinar\AppData\Local\Programs\Python\Python37-32\lib\multiprocessing\queues.py", line 99, in get
if not self._rlock.acquire(block, timeout):
PermissionError: [WinError 5] Access is denied
'''
在这个异常之后还有其他异常抛出,但是上面的错误是其他异常的“直接原因”。你知道吗
看起来并行处理有问题,所以在创建
RandomizedSearchCV()
对象时尝试设置n_jobs=1
。你知道吗另外,您可能想看看Parallalism in gridsearcCV is ending up with a permission error
希望这有帮助!你知道吗
相关问题 更多 >
编程相关推荐