我已经在Java代码中使用autoML构建了StackedEnsembleModel。但是,当我尝试将模型导出到mojo zip文件时,出现了“ water.exceptions.H2ONotFoundArgumentException:无法找到版本3的架构并键入:StackedEnsembleModel”的异常。
initH2OCloud();
try {
registerH2OAlgorithm();
AutoMLBuildSpec autoMLBuildSpec = new AutoMLBuildSpec();
Frame trainFrame = importAndParseFeatureFileToH2O("/home/data/MODEL.csv");
autoMLBuildSpec.input_spec.training_frame = trainFrame._key;
autoMLBuildSpec.input_spec.response_column = "level";
autoMLBuildSpec.build_models.exclude_algos = new Algo[2];
autoMLBuildSpec.build_models.exclude_algos[0] = Algo.DeepLearning;
autoMLBuildSpec.build_models.exclude_algos[1] = Algo.XGBoost;
autoMLBuildSpec.build_control.keep_cross_validation_models = true;
autoMLBuildSpec.build_control.keep_cross_validation_predictions = true;
autoMLBuildSpec.build_control.keep_cross_validation_fold_assignment = true;
autoMLBuildSpec.build_control.nfolds = 5;
autoMLBuildSpec.build_control.project_name = "test.prj";
autoMLBuildSpec.build_control.stopping_criteria.set_max_runtime_secs(300);
AutoML aml = AutoML.makeAutoML(Key.make(), new Date(), autoMLBuildSpec);
logger.info("Begin AutoML...");
long beginTick = Calendar.getInstance().getTime().getTime();
AutoML.startAutoML(autoMLBuildSpec).get();
long usedTick = Calendar.getInstance().getTime().getTime() - beginTick;
//save the leader model
String modelSavePath = "/home/data/tmp";
logger.info("best model: {}, RMSE: {}, MAE: {}, RSLE: {}。",
aml.leader()._key.toString(),
bigDecimalToString(new BigDecimal(Math.sqrt(aml.leader().mse())), 12),
bigDecimalToString(new BigDecimal(Math.sqrt(aml.leader().mae())), 12),
bigDecimalToString(new BigDecimal(Math.sqrt(aml.leader().rmsle())), 12));
logger.info("used {} seconds", usedTick/1000L);
logger.info("export to mojo...");
try {
aml.leader().getMojo().writeTo(new FileOutputStream(new File(modelSavePath + File.separator + aml.leader()._key + ".zip")));
logger.info("export finished.");
}
catch (Throwable t) {
logger.error("got exception", t);
}
logger.info("aml.leaderboard: ");
logger.info(aml.leaderboard());
}
finally {
stopH2OCloud();
}
当我调用aml.leader()。getMojo()。writeTo()方法时引发的异常。我正在使用h2o 3.22.0.1。 预先感谢。
答案 0 :(得分:0)
尝试使用aml.leader().getMojo().writeTo()
代替aml.leader().exportMojo(...)
。