R/pmml.glm.R
pmml.glm.Rd
Generate the PMML representation for a glm object from the package stats.
# S3 method for glm
pmml(
model,
model_name = "General_Regression_Model",
app_name = "SoftwareAG PMML Generator",
description = "Generalized Linear Regression Model",
copyright = NULL,
model_version = NULL,
transforms = NULL,
missing_value_replacement = NULL,
weights = NULL,
...
)
A glm object.
A name to be given to the PMML model.
The name of the application that generated the PMML.
A descriptive text for the Header element of the PMML.
The copyright notice for the model.
A string specifying the model version.
Data transformations.
Value to be used as the 'missingValueReplacement' attribute for all MiningFields.
The weights used for building the model.
Further arguments passed to or from other methods.
PMML representation of the glm object.
The function exports the glm model in the PMML GeneralRegressionModel format.
Note on glm models for 2-class problems: a dataset where the target categorical variable has more than 2 classes may be turned into a 2-class problem by creating a new target variable that is TRUE for a particular class and FALSE for all other classes. While the R formula function allows such a transformation to be passed directly to it, this may cause issues when the model is converted to PMML. Therefore, it is advised to create a new 2-class separately, and then pass that variable to glm(). This is shown in an example below.
if (FALSE) {
data(iris)
mod <- glm(Sepal.Length ~ ., data = iris, family = "gaussian")
mod_pmml <- pmml(mod)
rm(mod, mod_pmml)
data(audit)
mod <- glm(Adjusted ~ Age + Employment + Education + Income, data = audit, family = binomial(logit))
mod_pmml <- pmml(mod)
rm(mod, mod_pmml)
# Create a new 2-class target from a 3-class variable:
data(iris)
dat <- iris[, 1:4]
# Add a new 2-class target "Species_setosa" before passing it to glm():
dat$Species_setosa <- iris$Species == "setosa"
mod <- glm(Species_setosa ~ ., data = dat, family = binomial(logit))
mod_pmml <- pmml(mod)
rm(dat, mod, mod_pmml)
}