任何 n_jobs 进行交叉验证的内存泄漏

Ern*_*une 5 python memory-management scikit-learn jupyter-notebook

我正在运行一个代码来进行二进制分类并在之后预测标签。该代码与一个大小为 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)} 
Run Code Online (Sandbox Code Playgroud)

我正在使用一条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)
Run Code Online (Sandbox Code Playgroud)

model 是 sklearn 算法中的任何一种,我已经尝试过 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
Run Code Online (Sandbox Code Playgroud)

我怎么能解决这个问题?

Ern*_*une 0

我找到了这个问题的答案。似乎某些 scikit-learn 算法会根据分类特征的编码方法产生这些错误。就我而言,我必须从我使用的算法列表中删除:CategoricalNB()、Ridge()、ElasticNet() 和 GaussianProcessClassifier(),因为它们使用 StandardScaler() 或 MinMaxScaler() 产生错误。