RandomSearchCV 超慢 - 故障排除性能增强
Posted
技术标签:
【中文标题】RandomSearchCV 超慢 - 故障排除性能增强【英文标题】:RandomSearchCV super slow - troubleshooting performance enhancement 【发布时间】:2019-11-04 16:52:42 【问题描述】:我一直在编写以下随机森林分类脚本,但遇到了一些与随机搜索性能相关的问题 - 这需要很长时间才能完成,我想知道我做错了什么或者我可以做得更好以使其更快。
有人能建议我可以改进速度/性能吗?
提前致谢!
forest_start_time = time.time()
model = RandomForestClassifier()
param_grid =
'bootstrap': [True, False],
'max_depth': [80, 90, 100, 110],
'max_features': [2, 3],
'min_samples_leaf': [3, 4, 5],
'min_samples_split': [8, 10, 12],
'n_estimators': [200, 300, 500, 1000]
bestforest = RandomizedSearchCV(estimator = model,
param_distributions = param_grid,
cv = 3, n_iter = 10,
n_jobs = available_processor_count)
bestforest.fit(train_features, train_labels.ravel())
forest_score = bestforest.score(test_features, test_labels.ravel())
print(forest_score)
forest_end_time = time.time()
forest_duration = forest_start_time-forest_end_time
【问题讨论】:
您看过这些问题及其答案了吗? ***.com/questions/43640546/… 【参考方案1】:加快速度的唯一方法是 1) 减少功能或/和使用更多 CPU 内核 n_jobs = -1
:
bestforest = RandomizedSearchCV(estimator = model,
param_distributions = param_grid,
cv = 3, n_iter = 10,
n_jobs = -1)
【讨论】:
以上是关于RandomSearchCV 超慢 - 故障排除性能增强的主要内容,如果未能解决你的问题,请参考以下文章