任何n_job进行交叉验证时都会出现内存泄漏。

问题描述 投票:4回答:1

我正在运行一段代码来进行二进制分类,并在之后预测标签。该代码在一个大小为257673行和47列的特定数据库中完美运行。当我尝试使用91690行和10列的数据库时,我得到了错误调用。

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. The exit codes of the workers are {SIGKILL(-9)} 

我使用的是 cross validation 与...一致 n_job=-1

cross_val_score(model, X.drop(target,axis=1), X[target], cv=outer_cv, n_jobs=-1, scoring='neg_mean_squared_error')

outer_cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=1)

model 我试过AdaBoostClassifier、LogisticRegression、KNN、SVM、GradientBoosting、RandomForest、DecisionTreeClassifier......以及其他许多算法,但我一直得到同样的错误。

我试过改变 n_jobs=-2, 1, 2 但错误仍然存在。我在jupyter笔记本上运行代码,我的笔记本有以下属性。

Ubuntu 18.04.4 LTS
RAM: 15,5 Gb
Processor: Intel® Core™ i7-8550U CPU @ 1.80GHz × 8

我如何解决这个问题?

python memory-management scikit-learn jupyter-notebook
1个回答
0
投票

我找到了这个问题的答案.似乎一些scikit-learn算法会根据分类特征的编码方法产生这些错误。在我的案例中,我不得不从我使用的算法列表中删除。CategoricalNB()、Ridge()、ElasticNet()和GaussianProcessClassifier(),因为它们在使用StandardScaler()或MinMaxScaler()时都会产生错误。

© www.soinside.com 2019 - 2024. All rights reserved.