【问题标题】:error of grid search xgboost in h2o (version 3.20.0.2)h2o 中网格搜索 xgboost 的错误(版本 3.20.0.2)
【发布时间】:2018-11-27 22:39:52
【问题描述】:

我对 h2o 比较陌生,并试图将 xgboost 与网格搜索一起使用。我在具有 40 个内核和 26 gb 内存的 edgenode 上运行我的东西,使用 R 和 h2o 中的 h2o 包版本 3.20.0.2。只是 cpu 作为后端。

我运行 gbm 和 randomforest 没有问题(一些 gbm 需要大约 2 小时才能完成网格搜索,而且它们都运行良好)。但是,当我尝试运行 xgboost 时,总是会出错。

如果我运行一个没有网格搜索的简单示例,它将运行。但是,当我使用网格搜索运行 xgboost 时,我总是得到错误为“Error in .h2o.doSafeREST(h2oRestApiVersion = h2oRestApiVersion, urlSuffix = urlSuffix, : 意外的 CURL 错误:接收失败:连接已重置“。

我在网上进行了搜索,并试图弄清楚发生了什么。我发现了 LeDell 给出的两个例子,一个有效,另一个无效。

我在 R 中遇到错误,因为“.h2o.doSafeREST 中的错误(h2oRestApiVersion = h2oRestApiVersion, urlSuffix = urlSuffix, : Unexpected CURL error: Recv failure: Connection was reset”下面的代码 https://gist.github.com/ledell/71e0b8861d4fa35b59dde2af282815a5

library(h2o)
h2o.init()


# Load the HIGGS dataset
train <- h2o.importFile("https://s3.amazonaws.com/erin-data/higgs/higgs_train_10k.csv")
test <- h2o.importFile("https://s3.amazonaws.com/erin-data/higgs/higgs_test_5k.csv")
y <- "response"
x <- setdiff(names(train), y)
family <- "binomial"

#For binary classification, response should be a factor
train[,y] <- as.factor(train[,y])
test[,y] <- as.factor(test[,y])

# Some XGboost/GBM hyperparameters
hyper_params <- list(ntrees = seq(10, 1000, 1),
                     learn_rate = seq(0.0001, 0.2, 0.0001),
                     max_depth = seq(1, 20, 1),
                     sample_rate = seq(0.5, 1.0, 0.0001),
                     col_sample_rate = seq(0.2, 1.0, 0.0001))
search_criteria <- list(strategy = "RandomDiscrete",
                        max_models = 10, 
                        seed = 1)

# Train the grid
xgb_grid <- h2o.grid(algorithm = "xgboost",
                     x = x, y = y,
                     training_frame = train,
                     nfolds = 5,
                     seed = 1,
                     hyper_params = hyper_params,
                     search_criteria = search_criteria)


# Sort the grid by CV AUC
grid <- h2o.getGrid(grid_id = xgb_grid@grid_id, sort_by = "AUC", decreasing = TRUE)
grid_top_model <- grid@summary_table[1, "model_ids"]

另外,我的 edgenode 也出现错误 libgomp:线程创建失败:资源暂时不可用# [线程140207508600576也有错误]

Java 运行时环境检测到一个致命错误: SIGSEGV (0xb) at pc=xxxxxxxxxxx[线程140207503337216也有错误][线程140207504389888也有错误], pid=40095, tid=0x00007f849aaea700

JRE 版本:Java(TM) SE 运行时环境 (8.0_162-b12) (build 1.8.0_162-b12) Java VM:Java HotSpot(TM) 64 位服务器 VM(25.162-b12 混合模式 linux-amd64 压缩 oops)

有问题的框架:

C [libc.so.6+0x358e5] 退出+0x35

但我在下面运行代码时没有遇到任何问题(这也是 LeDell 在另一篇文章中给出的示例)

train <- h2o.importFile("https://s3.amazonaws.com/erin-data/higgs/higgs_train_10k.csv")

y <- "response"
x <- setdiff(names(train), y)

train[,y] <- as.factor(train[,y])

hyperparameters_xgboost <- list(ntrees = seq(10, 20, 10),
                     learn_rate = seq(0.1, 0.2, 0.1),
                    sample_rate = seq(0.9, 1.0, 0.1),
                     col_sample_rate = seq(0.5, 0.6, 0.1))

xgb <- h2o.grid("xgboost",
                x = x,
                y = y, 
                seed = 1,
                training_frame = train,
                max_depth = 3,
                hyper_params = hyperparameters_xgboost) 

因此,我不知道出了什么问题?最初我认为 xgboost 不起作用,然后我只使用 xgboost 成功运行(无网格)。然后我猜它一定是网格搜索部分,然后我确实通过后一个示例成功运行。我没有想法,想知道是否有人可能对我的错误有一些见解?

【问题讨论】:

  • 您提到您在网上找到了两个示例(由我发布),一个有效,另一个无效。您可以编辑您的帖子以添加不起作用的示例吗?谢谢!
  • 嗨 Erin,未运行的帖子在此处:gist.github.com/ledell/71e0b8861d4fa35b59dde2af282815a5
  • 嗨 Erin,请问这可能是版本问题吗?我没有机会尝试旧版本,但只是想知道。谢谢!
  • 我也有同样的问题!只要我不使用 nfolds,(而是使用验证框架)它就可以正常工作。但是在我添加 nfolds 后不久,它就会停止并且集群关闭!

标签: r h2o xgboost


【解决方案1】:

我无法在 H2O 3.20.0.2 上重现此错误:

> library(h2o)
> h2o.init()
 Connection successful!

R is connected to the H2O cluster: 
    H2O cluster uptime:         18 hours 58 minutes 
    H2O cluster timezone:       America/Los_Angeles 
    H2O data parsing timezone:  UTC 
    H2O cluster version:        3.20.0.2 
    H2O cluster version age:    6 days  
    H2O cluster name:           H2O_started_from_R_me_ves048 
    H2O cluster total nodes:    1 
    H2O cluster total memory:   3.28 GB 
    H2O cluster total cores:    8 
    H2O cluster allowed cores:  8 
    H2O cluster healthy:        TRUE 
    H2O Connection ip:          localhost 
    H2O Connection port:        54321 
    H2O Connection proxy:       NA 
    H2O Internal Security:      FALSE 
    H2O API Extensions:         XGBoost, Algos, AutoML, Core V3, Core V4 
    R Version:                  R version 3.5.0 (2018-04-23) 

> # Load the HIGGS dataset
> train <- h2o.importFile("https://s3.amazonaws.com/erin-data/higgs/higgs_train_10k.csv")
  |=================================================================================================| 100%
> test <- h2o.importFile("https://s3.amazonaws.com/erin-data/higgs/higgs_test_5k.csv")
  |=================================================================================================| 100%
> y <- "response"
> x <- setdiff(names(train), y)
> family <- "binomial"
> #For binary classification, response should be a factor
> train[,y] <- as.factor(train[,y])
> test[,y] <- as.factor(test[,y])
> # Some XGboost/GBM hyperparameters
> hyper_params <- list(ntrees = seq(10, 1000, 1),
+                      learn_rate = seq(0.0001, 0.2, 0.0001),
+                      max_depth = seq(1, 20, 1),
+                      sample_rate = seq(0.5, 1.0, 0.0001),
+                      col_sample_rate = seq(0.2, 1.0, 0.0001))
> search_criteria <- list(strategy = "RandomDiscrete",
+                         max_models = 10, 
+                         seed = 1)
> # Train the grid
> xgb_grid <- h2o.grid(algorithm = "xgboost",
+                      x = x, y = y,
+                      training_frame = train,
+                      nfolds = 5,
+                      seed = 1,
+                      hyper_params = hyper_params,
+                      search_criteria = search_criteria)
  |=================================================================================================| 100%
> 

【讨论】:

  • 谢谢你,艾琳!就我而言,我总是收到错误消息“.h2o.doSafeREST(h2oRestApiVersion = h2oRestApiVersion, urlSuffix = urlSuffix, : Unexpected CURL error: Recv failure: Connection was reset”。我已经让同事也运行它,他也遇到了和我一样的错误,他使用的是 3.18 版本的 h2o。我想知道这个错误可能指的是什么,我们可能需要在 edgenode 上设置什么?
  • 你能尝试在没有网格搜索的情况下重现吗?你能建立一个 5 折交叉验证的模型吗?你能用 XGBoost 建立一个简单的模型吗?您可以尝试限制 H2O 可以使用的线程数,使用 -nthreads 参数启动 h2o。我会尝试 10 和 20。
猜你喜欢
  • 2018-08-27
  • 2018-12-22
  • 2017-09-28
  • 2019-07-24
  • 2020-02-24
  • 1970-01-01
  • 2016-06-10
  • 2016-09-20
  • 2018-09-19
相关资源
最近更新 更多