我正在尝试加载经过训练的xgboost模型,以便在用java编写的自定义udf中使用。文件为zip格式,存储在hdfs中。
我试着用path类读取它,但它不起作用。
import org.apache.hadoop.fs.Path;
public EasyPredictModelWrapper loadModel(String xgBoostModelFile) {
if (model == null) {
synchronized (_lockObject) {
if (model == null) {
log.info("Model has not been loaded, loading ...");
try {
Path path = new Path(xgBoostModelFile);
model = new EasyPredictModelWrapper(MojoModel.load(path)); // Doesn't compile since MojoModel only takes string as an input.
} catch (IOException e) {
log.error("Got an exception while trying to load xgBoostModel \n", e);
}
}
}
}
return model;
}
我想成功加载model.zip
1条答案
按热度按时间x8goxv8g1#
在h20社区得到了答案。