autodeployai / pypmml

Python PMML scoring library
Apache License 2.0
75 stars 22 forks source link

Error parsing random forest regression model #6

Closed DalalAbadi closed 4 years ago

DalalAbadi commented 4 years ago

Py4JJavaError: An error occurred while calling z:org.pmml4s.model.Model.fromFile. : org.pmml4s.AttributeNotFoundException: Required attribute 'value' is missing. at org.pmml4s.xml.XmlAttrs$$anonfun$apply$1.apply(XmlAttrs.scala:27) at org.pmml4s.xml.XmlAttrs$$anonfun$apply$1.apply(XmlAttrs.scala:27) at scala.collection.MapLike$class.getOrElse(MapLike.scala:128) at scala.collection.AbstractMap.getOrElse(Map.scala:59) at org.pmml4s.xml.XmlAttrs.apply(XmlAttrs.scala:27) at org.pmml4s.xml.CommonBuilder$class.makeValue(CommonBuilder.scala:47) at org.pmml4s.xml.ModelBuilder.makeValue(ModelBuilder.scala:33) at org.pmml4s.xml.ModelBuilder$$anon$3$$anonfun$build$1.applyOrElse(ModelBuilder.scala:113) at org.pmml4s.xml.ModelBuilder$$anon$3$$anonfun$build$1.applyOrElse(ModelBuilder.scala:111) at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) at org.pmml4s.xml.XmlUtils$class.traverseElems(XmlUtils.scala:61) at org.pmml4s.xml.ModelBuilder.traverseElems(ModelBuilder.scala:33) at org.pmml4s.xml.ModelBuilder$$anon$3.build(ModelBuilder.scala:111) at org.pmml4s.xml.ModelBuilder$$anon$3.build(ModelBuilder.scala:102) at org.pmml4s.xml.XmlUtils$class.makeElems(XmlUtils.scala:123) at org.pmml4s.xml.ModelBuilder.makeElems(ModelBuilder.scala:33) at org.pmml4s.xml.ModelBuilder.makeDataDictionary(ModelBuilder.scala:102) at org.pmml4s.xml.ModelBuilder.makeModel(ModelBuilder.scala:56) at org.pmml4s.xml.ModelBuilder.build(ModelBuilder.scala:43) at org.pmml4s.xml.ModelBuilder.build(ModelBuilder.scala:33) at org.pmml4s.xml.XmlUtils$class.makeElem(XmlUtils.scala:71) at org.pmml4s.xml.ModelBuilder$.makeElem(ModelBuilder.scala:138) at org.pmml4s.xml.XmlUtils$class.makeElem(XmlUtils.scala:73) at org.pmml4s.xml.ModelBuilder$.makeElem(ModelBuilder.scala:138) at org.pmml4s.xml.ModelBuilder$.fromXml(ModelBuilder.scala:149) at org.pmml4s.model.Model$.apply(Model.scala:670) at org.pmml4s.model.Model$.fromFile(Model.scala:657) at org.pmml4s.model.Model.fromFile(Model.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244) at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357) at py4j.Gateway.invoke(Gateway.java:282) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132) at py4j.commands.CallCommand.execute(CallCommand.java:79) at py4j.GatewayConnection.run(GatewayConnection.java:238) at java.lang.Thread.run(Thread.java:748)

During handling of the above exception, another exception occurred:

PmmlError Traceback (most recent call last)

in 2 3 # The model is from http://dmg.org/pmml/pmml_examples/KNIME_PMML_4.1_Examples/single_iris_dectree.xml ----> 4 model = Model.fromFile('myModel.xml') ~/anaconda3/lib/python3.7/site-packages/pypmml/model.py in fromFile(cls, name) 155 except Py4JJavaError as e: 156 je = e.java_exception --> 157 raise PmmlError(je.getClass().getSimpleName(), je.getMessage()) 158 159 @classmethod PmmlError: ('AttributeNotFoundException', "Required attribute 'value' is missing.")
scorebot commented 4 years ago

@DalalAbadi Which version of pypmml is used? And are you sure the model myModel.xml is from http://dmg.org/pmml/pmml_examples/KNIME_PMML_4.1_Examples/single_iris_dectree.xml? The model single_iris_dectree.xml is a decision tree classification model, not a random forest regression model.

I can not reproduce the issue above, I installed pypmml 0.9.3, and the model single_iris_dectree.xml can be loaded successfully.

scorebot commented 4 years ago

@DalalAbadi If you don't mind, could you attach the failed pmml model in the issue?

animator commented 4 years ago

@DalalAbadi i ran the tests for single_iris_dectree.xml and pypmml was working perfectly fine (both Model.fromFile() and .predict()). Can you please attach the xml file as @scorebot requested.

scorebot commented 4 years ago

@DalalAbadi I close the current issue now. You are free to open a new issue if you still have a problem. In order to investigate and debug easily, pls attach your PMML model or input some key PMML model snippets.