英文:
h2o - Could not find or load main class code 7 error
问题
我已在R中使用以下代码构建了一个GBM模型。
gbm_model_sample <- h2o.gbm(x = c(1:78, 80:688), y = 79, training_frame = train.h2o, seed = 0xDECAF, ntrees = 1000, max_depth = 4, learn_rate = 0.1, stopping_rounds = 50, min_rows = 50, distribution = "bernoulli", ignore_const_col = F, histogram_type = 'QuantilesGlobal', sample_rate = 0.7, col_sample_rate = 0.7, keep_cross_validation_models = T)
我保存了模型,并将Mojo对象命名为:
h2o.download_mojo(gbm_model_sample, get_genmodel_jar = T)
该Mojo对象被保存为"GBM_model_R_1586221409024_1.zip",位于我的工作目录中。
现在,我使用函数h2o.mojo_predict_csv
和/或h2o.mojo_predict_df
在测试数据帧上进行预测,但是在这里我遇到以下错误:
对于h2o.mojo_predict_csv
:
h2o.mojo_predict_csv('Test_sample_.csv', 'GBM_model_R_1586221409024_1.zip', genmodel_jar_path = 'h2o-genmodel.jar', verbose = F)
对于h2o.mojo_predict_df
:
h2o.mojo_predict_df(test, 'GBM_model_R_1586221409024_1.zip', verbose = T)
当我使用相同的测试数据并在R内部使用h2o.predict
函数时,一切正常。然而,上述两个之前正常运行的代码现在开始出现上述错误。我加载的软件包如下。是什么导致了这个错误?在网上我没有找到太多关于这个错误的信息。
library(rJava)
require(h2o)
require(readr)
require(dplyr)
require(forcats)
require(ggplot2)
require(scales)
require(caret)
require(stringr)
library(data.table)
require(getPass)
英文:
I have built a GBM model in R with the below code.
gbm_model_sample <- h2o.gbm(x = c(1:78,80:688), y =79, training_frame = train.h2o, seed = 0xDECAF,ntrees = 1000, max_depth = 4,learn_rate = 0.1,stopping_rounds=50,min_rows = 50,distribution ="bernoulli",ignore_const_col=F,
histogram_type='QuantilesGlobal',sample_rate=0.7,col_sample_rate=0.7,keep_cross_validation_models = T)
The model gets built and i save the Mojo object as :
h2o.download_mojo(gbm_model_sample,get_genmodel_jar = T)
which is saved as "GBM_model_R_1586221409024_1.zip" in my working directory.
Now i use function h2o.mojo_predict_csv
and/or h2o.mojo_predict_df
to predict on test data frame which is where i get the error as below
for h2o.mojo_predict_csv
h2o.mojo_predict_csv('Test_sample_.csv','GBM_model_R_1586221409024_1.zip',genmodel_jar_path = 'h2o-genmodel.jar',verbose = F)
for h2o.mojo_predict_df
h2o.mojo_predict_df(test, 'GBM_model_R_1586221409024_1.zip',verbose = T)
when i use the same test and use the within R h2o.predict
it works completely fine , however the above two codes which had been working fine for me before have started giving the errors as above. My packages loaded are as below. What is causing this error? i haven't manage to find much info on this online.
library(rJava)
require(h2o)
require(readr)
require(dplyr)
require(forcats)
require(ggplot2)
require(scales)
require(caret)
require(stringr)
library(data.table)
require(getPass)
答案1
得分: 2
虽然听起来有些愚蠢,但在h2o中似乎存在一个错误,当设置了一个工作目录并且该目录的名称中有空格时,会出现问题。例如:"c:\test folder\model\"
,如果您将其更改为"c:\test_folder\model\"
或"c:\testfolder\model\"
,那么我们就不会出现上述错误。H2o在那些目录中写入文件变得困难,这些目录的地址之间存在空格。
英文:
As silly as it sounds, there seems to be a bug in h2o which occurs when have a working directory set which has empty spaces in its name. e.g. "c:\test folder\model\"
, if you change this to "c:\test_folder\model\
" or "c:\testfolder\model\"
, then we don't get the above error. H2o has difficult writing the files to those directories with address where there are empty spaces in between.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论