As of KNIME 2.0 there is the possibility to import (v3.0, v3.1, v3.2) and export (v3.1) PMML models into and out of KNIME. The PMML Reader and PMML Writer nodes are the corresponding nodes and can be found in the IO category. If you want to use R within KNIME you have to download the R plugin for KNIME. If you have no local R installation you may want to download the R binaries as well, which are also available via KNIME's Update Site. In order to use a local R installation you can go to File/Preferences.../KNIME/R/". Here you can browse to your local R installation, which KNIME will use from now on in all R (Local) nodes. In order to use the R PMML export you have to start the R GUI, click packages/install packages and select the "pmml" package. The embedded R installation which comes with the R binaries' plugin, already contains this pmml package. Having all required libraries and plugins installed, you can start to train an R model using the R Learner node from the R/Local category. The picture below shows the example flow that is also attached: The following example R script learns a decision tree based on the Iris-Data and exports this as PMML and as an R model which is understood by the R Predictor node:
library(rpart); library(pmml); dt <- rpart(class~., R) r_pmml <- pmml(dt) write(toString(r_pmml), file="C:/R.pmml") R<-dt
The export of the generated R object can be done in two ways:
either the R object is converted to PMML directly with the R code or
the R object is passed to the out-port and then converted by the build-in R-to-PMML converter node. It can then be written to file by the PMML Writer node.
Note, PMML written by the PMML Writer node may contain less information as the PMML exported by the R code. Once the PMML file is written you can use the PMML Reader node to import it and connect it to the native KNIME Decision Tree Predictor node. In this way you can export, import, and convert R models to PMML while at the same time use R models with the R Predictor or any other Predictor node using PMML as input.