12

I have a PMML file which I am trying to import/read in R to do some analysis based on it. I couldn't find a suitable function to read the model, although I found a package that is related to PMML. Is there is a simple way to read this type of file into R?

Thanks,

Error404
  • 6,959
  • 16
  • 45
  • 58
  • as far as I can tell the answer to this question is still "it depends what kind of model you're trying to read, but there is no general pre-packaged solution". The problem is that someone would have to write the XML-to-R object mapping function, which has at present only been done for subclasses (trees; `partykit`; association rules, `arules`). It would be to hard to write that particular XML -> GLM rule, but would that actually solve your problem? – Ben Bolker Dec 31 '15 at 15:32
  • @BenBolker Yes -- I think an answer along the lines of "here are all the cases where you can use a pre-packaged solution, and then here's an example of how to do the object mapping where no pre-packaged solution exists" would be much better than the piecemeal answers here. – C8H10N4O2 Jan 04 '16 at 13:16
  • You really need to switch the checked solution to the correct answer that you awarded the bounty to, otherwise readers incorrectly think that you can import PMML from other systems when you can not. – Hack-R Nov 10 '16 at 16:37

5 Answers5

11

Unfortunately, it is not possible to import a model in PMML format in order to predict the classes of some instances using R.

The pmml package only allow you to train a model in R and then export it.

jllopezpino
  • 868
  • 2
  • 9
  • 17
  • Yep, though the Rdocumentation link Dirk Eddelbuettel seems to allow you to read a PMML file - http://www.rdocumentation.org/packages/arules/functions/pmml – JobJob May 22 '14 at 15:58
6

There is now a way to read PMML objects into R, using the great "partykit" package.

I tried it out with a node from SPSS and it works.

Here is the link to the vignette explaining how: https://cran.r-project.org/web/packages/partykit/vignettes/constparty.pdf

eflores89
  • 339
  • 2
  • 10
  • 27
2

There is currently no way to import a model via PMML unless the model was created using the arules package. The authors of that package have provided a way to import/export arules models

http://cran.r-project.org/web/packages/arules/index.html

user1775655
  • 317
  • 2
  • 8
2

Although it's a long time ago, I still want to share that you can use the "reticulate" to call the python pypmml package to implement your ideas in R, and in order to be more friendly and make the prediction look more like the predict function in R, I will It is encapsulated, the address of the package is here "https://github.com/xianglinZ/RLoadPmml"

0

Yes there is even a pmml package.

And see the Rdocumentation.org result for searching for pmml

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • 2
    I don't think there is an IMPORT option in the R PMML package. – rishiehari Apr 08 '14 at 17:07
  • 4
    The provided link only reads PMML models created by the arules package, so it's not applicable for all PMML models... – Omri374 Jan 11 '15 at 09:44
  • 2
    but what is the point of being able to read pmml files generated only from that tool. After all pmml is a standard. and the whole point is being interoperable – DesirePRG Nov 12 '15 at 11:05