在h2o(R)中堆叠不同的模型(包括rf,glm)

时间:2018-02-12 16:00:06

标签: java r h2o ensemble-learning

我对R中的h2o.stackedEnsemble有疑问。当我尝试从GLM模型(或任何其他模型和GLM)创建集合时,我收到以下错误:

DistributedException from localhost/127.0.0.1:54321: 'null', caused by java.lang.NullPointerException

DistributedException from localhost/127.0.0.1:54321: 'null', caused by java.lang.NullPointerException
    at water.MRTask.getResult(MRTask.java:478)
    at water.MRTask.getResult(MRTask.java:486)
    at water.MRTask.doAll(MRTask.java:390)
    at water.MRTask.doAll(MRTask.java:396)
    at hex.StackedEnsembleModel.predictScoreImpl(StackedEnsembleModel.java:123)
    at hex.StackedEnsembleModel.doScoreMetricsOneFrame(StackedEnsembleModel.java:194)
    at hex.StackedEnsembleModel.doScoreOrCopyMetrics(StackedEnsembleModel.java:206)
    at hex.ensemble.StackedEnsemble$StackedEnsembleDriver.computeMetaLearner(StackedEnsemble.java:302)
    at hex.ensemble.StackedEnsemble$StackedEnsembleDriver.computeImpl(StackedEnsemble.java:231)
    at hex.ModelBuilder$Driver.compute2(ModelBuilder.java:206)
    at water.H2O$H2OCountedCompleter.compute(H2O.java:1263)
    at jsr166y.CountedCompleter.exec(CountedCompleter.java:468)
    at jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:263)
    at jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:974)
    at jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1477)
    at jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)
Caused by: java.lang.NullPointerException

Error: DistributedException from localhost/127.0.0.1:54321: 'null', caused by java.lang.NullPointerException

当我堆叠任何其他模型时,不会出现错误,只出现在GLM中。当然,我使用相同的折叠进行交叉验证。

用于训练模型和整体的一些示例代码:

glm_grid <- h2o.grid(algorithm = "glm",
                     family = 'binomial',
                     grid_id = "glm_grid",
                     x = predictors,
                     y = response,
                     seed = 1,
                     fold_column = "fold_assignment",
                     training_frame = train_h2o,
                     keep_cross_validation_predictions = TRUE,
                     hyper_params = list(alpha = seq(0, 1, 0.05)),
                     lambda_search = TRUE,
                     search_criteria = search_criteria,
                     balance_classes = TRUE,
                     early_stopping = TRUE)

glm <- h2o.getGrid("glm_grid",
                  sort_by="auc",
                  decreasing=TRUE)

ensemble <- h2o.stackedEnsemble(x = predictors,
                                y = response,
                                training_frame = train_h2o,
                                model_id = "ens_1",
                                base_models = glm@model_ids[1:5])

1 个答案:

答案 0 :(得分:1)

这是一个错误,您可以跟踪修复程序here的进度(这应该在下一个版本中修复,但它可能会更快修复并在每晚版本中提供)。

我打算建议在循环中训练GLM或应用函数(而不是使用h2o.grid())作为临时解决方法,但不幸的是,同样的错误发生。