尝试在 java 中加载时 jpmml 中的 InvalidFeatureException
InvalidFeatureException in jpmml while trying to load in java
我的 pmml 文件 link。由 R-Tool 生成
这是我的 java 代码..
PMML model = null;
File inputFilePath = new File("/home/equation/iris_rf.pmml");
try (InputStream is = new FileInputStream(inputFilePath)) {
model = org.jpmml.model.PMMLUtil.unmarshal(is);
} catch (Exception e) {
throw e;
}
// construct a tree predictor based on the PMML
ModelEvaluator<TreeModel> modelEvaluator = new TreeModelEvaluator(model);
System.out.println(modelEvaluator.getSummary());
异常 ---
Exception in thread "main" org.jpmml.evaluator.InvalidFeatureException: PMML
at org.jpmml.evaluator.ModelEvaluator.selectModel(ModelEvaluator.java:528)
at org.jpmml.evaluator.tree.TreeModelEvaluator.<init>(TreeModelEvaluator.java:64)
at com.girnarsoft.Pmml.main(Pmml.java:24)
有什么想法吗?为什么会出现此错误?
您必须实例化 org.jpmml.evaluator.ModelEvaluator
个与您的 PMML 文件的顶级模型元素相匹配的子类。
目前,您正在实例化 org.jpmml.evaluator.tree.TreeModelEvaluator
,它对应于 TreeModel
element. However, you should be instantiating org.jpmml.evaluator.mining.MiningModelEvaluator
instead, as the top-level Model element in your PMML file is the MiningModel
element。
一般来说,您应该使用 ModelEvaluatorFactory#newModelEvaluator(PMML)
工厂方法构造 ModelEvaluator
个实例。
我的 pmml 文件 link。由 R-Tool 生成
这是我的 java 代码..
PMML model = null;
File inputFilePath = new File("/home/equation/iris_rf.pmml");
try (InputStream is = new FileInputStream(inputFilePath)) {
model = org.jpmml.model.PMMLUtil.unmarshal(is);
} catch (Exception e) {
throw e;
}
// construct a tree predictor based on the PMML
ModelEvaluator<TreeModel> modelEvaluator = new TreeModelEvaluator(model);
System.out.println(modelEvaluator.getSummary());
异常 ---
Exception in thread "main" org.jpmml.evaluator.InvalidFeatureException: PMML
at org.jpmml.evaluator.ModelEvaluator.selectModel(ModelEvaluator.java:528)
at org.jpmml.evaluator.tree.TreeModelEvaluator.<init>(TreeModelEvaluator.java:64)
at com.girnarsoft.Pmml.main(Pmml.java:24)
有什么想法吗?为什么会出现此错误?
您必须实例化 org.jpmml.evaluator.ModelEvaluator
个与您的 PMML 文件的顶级模型元素相匹配的子类。
目前,您正在实例化 org.jpmml.evaluator.tree.TreeModelEvaluator
,它对应于 TreeModel
element. However, you should be instantiating org.jpmml.evaluator.mining.MiningModelEvaluator
instead, as the top-level Model element in your PMML file is the MiningModel
element。
一般来说,您应该使用 ModelEvaluatorFactory#newModelEvaluator(PMML)
工厂方法构造 ModelEvaluator
个实例。