[h2o MOJO预测与h2o.predict对于GBM都不同]] << [

问题描述 投票:0回答:1
h2o.predicth2o.mojo_predict_df对于相同的测试数据集获得不同的预测。比较时-大约50%的记录具有相同的概率,但是50%的记录不同,其中某些概率急剧变化=例如。同一班级为0.88至0.55。

使用的建模算法是h2o.gbmh2o.download_mojo(gbm_model,get_genmodel_jar = T)

我正在尝试研究,并且发现了更多类似问题但没有解决方案的帖子:

Reproduce predictions with MOJO file of a H2O GBM model

GLM model: h2o.predict gives very different results depending on number of rows used in the validation data

Why do I get different predictions with MOJO?

到目前为止使用的代码如下:

# h2o start the cluster h2o.init(nthreads=10,min_mem_size = '80g') # variables predictors=c(1:76,78:681) response=77 # getting datasets ready model_ready_df = model_ready_df %>% mutate_if(is.character,as.factor) train.h2o = as.h2o(model_ready_df) poc_test = poc_test %>% mutate_if(is.character,as.factor) test.h2o <- as.h2o(poc_test) # build model gbm_model <- h2o.gbm(x = predictors, y =response, 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) # save model object h2o.download_mojo(gbm_model,get_genmodel_jar = T) # predict preds=as.data.frame(h2o.predict(gbm_model,test.h2o)) preds2=h2o.mojo_predict_df(poc_test, 'GBM_model_R_1576045840818_1.zip',genmodel_jar_path = 'h2o-genmodel.jar',verbose = F) # save fwrite(preds,"pred_usual.csv") fwrite(preds2,"pred_mojo.csv")

示例

enter image description here

我从h2o.predict和h2o.mojo_predict_df获得了相同测试数据集的不同预测。比较时-大约50%的记录具有相同的概率,但是50%的记录具有...

java r prediction h2o gbm
1个回答
0
投票
h2o.mojo_predict_d f将数据帧转换为csv,然后从本质上运行h2o.mojo_predict_csv。因此,在此写入和解析变量的过程中-某些变量可能具有格式错误地写入到CSV中的格式,从而导致结果差异。一个示例是R的科学计数法,如果您的数字显示为e+10。将这些内容写入csv后,格式会混合在一起。使用options(scipen=999)进行更正,然后运行mojo功能。结果应该相同。
© www.soinside.com 2019 - 2024. All rights reserved.