# NOT RUN {
# Load the standard iris dataset
data(iris)
# Create a linear model and convert it to PMML
mod <- lm(Sepal.Length ~ ., iris)
pmod <- pmml(mod)
# Create additional output nodes
onodes0 <- make_output_nodes(
name = list("OutputField", "OutputField"),
attributes = list(list(
name = "dbl",
optype = "continuous"
), NULL),
expression = list("ln(x)", "ln(x/(1-x))")
)
onodes2 <- make_output_nodes(
name = list("OutputField", "OutputField"),
attributes = list(
list(
name = "F1",
dataType = "double", optype = "continuous"
),
list(name = "F2")
)
)
# Create new pmml objects with the output nodes appended
pmod2 <- add_output_field(
xml_model = pmod, outputNodes = onodes2, at = "End",
xformText = NULL, nodeName = NULL, attributes = NULL,
whichOutput = 1
)
pmod2 <- add_output_field(
xml_model = pmod, outputNodes = onodes0, at = "End",
xformText = NULL, nodeName = NULL,
attributes = NULL, whichOutput = 1
)
# Create nodes with attributes and transformations
pmod3 <- add_output_field(xml_model = pmod2, outputNodes = onodes2, at = 2)
pmod4 <- add_output_field(
xml_model = pmod2, xformText = list("exp(x) && !x"),
nodeName = "Predicted_Sepal.Length"
)
att <- list(datype = "dbl", optpe = "dsc")
pmod5 <- add_output_field(
xml_model = pmod2, nodeName = "Predicted_Sepal.Length",
attributes = att
)
# }
Run the code above in your browser using DataLab