tests/testthat/test_pmml.gbm.R

data(audit)


test_that("pmml.gbm final Segment contains modelName attribute", {
  skip_if_not_installed("gbm")
  library(gbm)

  audit_dat <- audit[, -c(1, 4, 6, 9, 10, 11, 12)]
  
  # currently gives: setting `distribution = "multinomial"` is ill-advised as it is currently broken. It exists only for backwards compatibility. Use at your own risk.
  expect_warning(fit <- gbm(Adjusted ~ ., data = audit_dat, n.trees = 3, interaction.depth = 4, distribution = "multinomial"))
  
  p_fit <- pmml(fit)

  expect_equal(xmlGetAttr(p_fit[[3]][[3]][[7]][[2]], name = "modelName"), "GBM_Model")
  expect_equal(xmlGetAttr(p_fit[[3]][[3]][[7]][[2]], name = "normalizationMethod"), "softmax")
})

Try the pmml package in your browser

Any scripts or data that you put into this service are public.

pmml documentation built on March 26, 2026, 5:07 p.m.