## Not run:
# The following commands can be run from R given a text file "class_table.csv" which,
# for example, may contain the 2 lines:
# setosa,1
# versicolor,2
#
# Naturally, the file does not contain the hash character. This file contains information
# which maps the input field so that its value 'setosa' is mapped to the value 1 and its
# value 'versicolor' is mapped to 2. See the manual of the 'pmmlTransformations' package for
# details
# Create a pmmlTransformations object
library(pmmlTransformations)
irisBox <- WrapData(iris)
# Transform the 'Sepal.Length' variable to 'dd1' via a chain
irisBox <- ZScoreXform(irisBox,xformInfo = "Sepal.Length->d1")
irisBox <- MinMaxXform(irisBox,xformInfo = "d1->dd1")
#transform the same variable 'class' to many different derived variables
irisBox <- MapXform(irisBox,xformInfo = "[Species->d_Species][string->double]",
table="class_table3.csv",defaultValue="-1",mapMissingTo="1")
irisBox <- NormDiscreteXform(irisBox,inputVar="Species")
# make a clustering model calculating 'Species' using the derived fields, then convert
# to PMML format
fit <- kmeans(irisBox$data[,c(6:11)],5)
pmml_fit <- pmml(fit, predictedField="Species")
# now we imagine that we realize the fields we used were actually derived from the basic iris
# data set. First we put the transformation information in PMML format.
pmml_trans <- pmml(NULL, transforms=irisBox)
# Finally, we can see the combined PMML file
pmml_combined <- pmml(pmml_fit, transforms=pmml_trans)
## End(Not run)
Run the code above in your browser using DataLab