# NOT RUN {
# Load the standard iris dataset:
data(iris)
# Wrap the data:
iris_box <- xform_wrap(iris)
# Perform a transform on the Sepal.Length field:
# the value is squared and then divided by 100
iris_box <- xform_function(iris_box,
orig_field_name = "Sepal.Length",
new_field_name = "Sepal.Length.Transformed",
expression = "(Sepal.Length^2)/100"
)
# Combine two fields to create another new feature:
iris_box <- xform_function(iris_box,
orig_field_name = "Sepal.Width, Petal.Width",
new_field_name = "Width.Sum",
expression = "Sepal.Width + Sepal.Length"
)
# Create linear model using the derived features:
fit <- lm(Petal.Length ~
Sepal.Length.Transformed + Width.Sum, data = iris_box$data)
# Create pmml from the fit:
fit_pmml <- pmml(fit, transform = iris_box)
# }
Run the code above in your browser using DataLab