为交叉验证指定nfolds时出现h2o deeplearning错误

时间:2018-08-24 06:49:26

标签: r h2o sparkling-water

这个问题现在已经解决了吗?我遇到相同的错误消息。

用例:我正在使用h2o的deeplearning()函数进行二进制分类。在下面,我提供了与实际用例大小相同的随机生成的数据。系统规格:

# R version 3.3.2 (2016-10-31)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows >= 8 x64 (build 9200)
# h2o version h2o_3.20.0.2

我目前正在学习如何使用h2o,因此我已经使用了该功能。在我指定交叉验证的参数之前,一切都会顺利进行。

在为交叉验证指定nfolds参数时发生问题。有趣的是,我可以为nfolds指定较低的值,然后一切正常。对于我的用例,即使nfolds> 3也会产生错误消息(请参见下文)。我在下面提供了一个示例,在这里我可以指定nfolds <7(不是非常一致,有时最多nfolds = 3)。在这些值之上,REST API给出上述错误:object not found for argument: key

# R version 3.3.2 (2016-10-31)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows >= 8 x64 (build 9200)
# h2o version h2o_3.20.0.2


#does not matter whether run on debian or windows, does not matter how many threads are used
#error occurs with options for cross validation, otherwise works fine
#no error occurs with specifying a low nfold number(in my actual use case, maximum of 3 folds possible without running into that error message)

require(h2o)
h2o.init(nthreads = -1)

x = matrix(rnorm(900*96, mean=10, sd=2), nrow=900, ncol=96)
y = sample(size=900, x=c(0,1), replace=T)

sampleData = cbind(x, y)
sampleData = data.frame(sampleData)
sampleData[,97] = as.factor(sampleData[,97])

m = h2o.deeplearning(x = 1:96, y = 97,
                     training_frame = as.h2o(sampleData), reproducible = T,
                     activation = "Tanh", hidden = c(64,16), epochs = 10000, verbose=T,
                     nfolds = 4, balance_classes = TRUE, #Cross-validation
                     standardize = TRUE, variable_importances = TRUE, seed=123,
                     stopping_rounds=2, stopping_metric="misclassification", stopping_tolerance=0.01, #early stopping
)

performance = h2o.performance(model = m)
print(performance)

######### gives error message
# ERROR: Unexpected HTTP Status code: 404 Not Found (url = http://localhost:xxxxx/3/Models/DeepLearning_model_R_1535036938222_489)
# 
# water.exceptions.H2OKeyNotFoundArgumentException
# [1] "water.exceptions.H2OKeyNotFoundArgumentException: Object 'DeepLearning_model_R_1535036938222_489' not found for argument: key"

我不明白为什么它仅对nfold的低值有效。有什么建议么?我在这里想念什么?我已经在Google网上论坛中搜索了大多数与远程相关的线程,也在此处进行了stackoverflow搜索,但是没有成功。如果这与上面建议的h2o 3.x的API更改有关(尽管那是18个月前的事……),我将非常感谢一些关于如何正确指定使用h2o进行CV语法的记录片。 )。预先感谢!

1 个答案:

答案 0 :(得分:0)

这是由将verbose参数设置为True引起的错误,解决方法是将verbose参数保留为默认值FALSE。我创建了一张吉拉票来跟踪问题here