问题
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