【问题标题】:XGBOOST killing Jupyter Notebook KernelXGBOOST 杀死 Jupyter Notebook 内核
【发布时间】:2021-10-24 16:13:20
【问题描述】:

我目前正在尝试在 Jupyter 笔记本上本地运行 XGBOOST 模型。我有一个形状为 (68799, 85) 的数据集。这个想法是使用 Optuna 进行超参数调整。但是,Jupyter 笔记本上的内核会因消息The kernel appears to have died. It will restart automatically. 而死去

当我在任何模型拟合/调整开始之前将我的训练集、测试集和验证集转换为 DMatrix 数据类型时,笔记本就会死机:

features = df.drop(["Target"], axis = 1) # X
target = df["Target"] # Y
    
train_ratio = 0.8
val_ratio = 0.1
test_ratio = 0.1

# Creating train and test sets
X_train, X_test, y_train, y_test = train_test_split(features,
                                                    target,
                                                    test_size = 1 - train_ratio,
                                                    random_state = 42)

# Creating validation set
X_val, X_test, y_val, y_test = train_test_split(X_test,
                                                y_test,
                                                test_size = test_ratio/(test_ratio + val_ratio),
                                                random_state = 42) 
    
# Converting to DMatrix
    
d_train = xgb.DMatrix(X_train,
                          label = y_train)
    
d_test = xgb.DMatrix(X_test,
                         label = y_test)
    
d_val = xgb.DMatrix(X_val,
                        label = y_val)

我最终将在 AWS 上预置 EC2 资源,但我想检查 Jupyter 是否崩溃,因为我有一个大型数据集,或者 Jupyter 甚至我的机器是否存在一些潜在问题:

Processor: 2.6 GHz 6-Core Intel Core i7

Memory: 16 GB 2667 MHz DDR4

Graphics: AMD Radeon Pro 5300M 4 GB Intel UHD Graphics 630 1536 MB

以前有人遇到过这样的问题吗?在模型训练之前内核就死掉了,这似乎很奇怪。

【问题讨论】:

  • 您应该通过在应该提供真实错误消息的 python shell(jupyter 外部)中运行代码来获得更有意义的错误消息。

标签: python machine-learning jupyter-notebook xgboost


【解决方案1】:

我在每个讨论此问题的网页上都尝试了所有内容。唯一对我有用的是降级到以前的 xgboost 版本。这是我所做的(在我的 MacOS 终端中)有效的方法:

pip uninstall xgboost
pip install xgboost==0.80

在这篇文章的上面找到了答案(非常感谢回答它的Евгений Куприков):XGBoost crashing kernel in jupyter notebook

【讨论】:

    猜你喜欢
    • 2016-05-14
    • 1970-01-01
    • 2016-06-26
    • 1970-01-01
    • 2019-01-17
    • 2020-07-04
    • 2021-11-03
    • 2022-12-15
    相关资源
    最近更新 更多