# NOT RUN {
library(glmnet)
# Create a simple predictor (x) and response(y) matrices:
x <- matrix(rnorm(100 * 20), 100, 20)
y <- rnorm(100)
# Build a simple gaussian model:
model1 <- cv.glmnet(x, y)
# Output the model in PMML format:
model1_pmml <- pmml(model1)
# Shift y between 0 and 1 to create a poisson response:
y <- y - min(y)
# Give the predictor variables names (default values are V1,V2,...):
name <- NULL
for (i in 1:20) {
name <- c(name, paste("variable", i, sep = ""))
}
colnames(x) <- name
# Create a simple poisson model:
model2 <- cv.glmnet(x, y, family = "poisson")
# Output the regression model in PMML format at the lambda
# parameter = 0.006:
model2_pmml <- pmml(model2, s = 0.006)
# }
Run the code above in your browser using DataLab