How to specify the file name when saving the model using h2o package from R

大兔子大兔子 提交于 2019-12-01 21:47:18

问题


I am trying to save the model build using the function: h2o.saveModel(), based on function description on page 159 of the H2O user manual for R, the arguments only consider path. I looked at other similar function such as: h2o.saveModelDetails() but it uses the same argument. Please advise if there any another way to specify the name of the model.


回答1:


The name of the model file will be determined by the ID of the model. So if you specify model_id when training your model, then you can customize it. Right now there is no way to change the ID of the model after it's been trained.

The file can be renamed once saved:

h2o.saveModel(object = fit, path = path.value, force = TRUE) # force overwriting
name <- file.path(path.value, fileName) # destination file name at the same folder location
file.rename(file.path(path.value, fit@model_id), name)



回答2:


Here a possible way to do it:

output_dir <-getwd()
DRF_MO <- h2o.saveModel(object=aml, path=output_dir, force=TRUE)
DRF_MO <- file.path(output_dir, aml@algorithm) 
file.rename(file.path(output_dir, aml@model_id), DRF_MO)


来源:https://stackoverflow.com/questions/48833097/how-to-specify-the-file-name-when-saving-the-model-using-h2o-package-from-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!