Marshalling of 'parsnip' objects

# S3 method for model_fit
marshal(x, ...)

# S3 method for model_fit
marshallable(...)

Arguments

x

A parnsip:model_fit object.

...

Not used.

Value

A marshalled object as described in marshal().

Details

The fit element of the model_fit object is marshalled.

Examples

if (requireNamespace("parsnip", quietly = TRUE) && requireNamespace("xgboost", quietly = TRUE)) {
  library(parsnip)
  
  ## Adopted from example("boost_tree", package = "parsnip")
  model <- boost_tree(mode = "classification", trees = 20L, engine = "xgboost")  
  model <- set_mode(model, "regression")
  fit <- fit(model, mpg ~ ., data = datasets::mtcars)
  
  ## Marshal
  fit_ <- marshal(fit)

  ## Unmarshal
  fit2 <- unmarshal(fit_)

  ## Marshal again
  fit2_ <- marshal(fit2)

  ## Assert identity
  stopifnot(
    all.equal(fit2_, fit_)
  )
  
  fit3 <- unmarshal(fit2_)

  ## Assert identity
  stopifnot(
    all.equal(fit3, fit2)
  )
}  
#> Error in assert_no_references(res): Detected a non-exportable reference (‘externalptr’ of class ‘xgb.Booster.handle’) in one of the globals (‘marshalled’ of class ‘_xgb.Booster’) used in the future expression