EXPERIMENTAL STATE - MAY NOT WORK AS INTENDED

Score code will only be generated successfully for supported models. Other models and frameworks will be added in due time. Use create_scoreSample() to get a structure sample

Disclaimer: The score code that is generated is designed to be a working template for an R model, but is not guaranteed to work out of the box for scoring, publishing, or validating the model.

codegen(model, path, rds, libs, inputs, ...)

# S3 method for class 'lm'
codegen(model, path = "scoreCode.R", rds = "model.rds", libs = c())

# S3 method for class 'glm'
codegen(
  model,
  path = "scoreCode.R",
  rds = "model.rds",
  cutoff = 0.5,
  libs = c()
)

# S3 method for class 'workflow'
codegen(
  tm_workflow,
  path = "scoreCode.R",
  rds = "model.rds",
  inputs = NULL,
  libs = c(),
  referenceLevel = NULL
)

Arguments

model

model object (lm, glm ...)

path

file name and path to write

rds

.rds file name to be called

libs

vector of libraries to be added to the code. Some may be guessed from the type.

inputs

define inputs as the passed vector instead of guessed

...

to be passes to individual code generators

Value

a code string

Methods (by class)

  • codegen(lm): Code generator for lm class models

  • codegen(glm): generator for glm class models, specifically logistic regression

  • codegen(workflow): generator for tidymodels workflow class models

Examples


if (FALSE) { # \dontrun{
# SAS viya doesn't play nice with variables with '.' in the names
colnames(iris) <- gsub("\\.", "_", colnames(iris))

# simple regression
model <- lm(Petal.Length ~ ., data = iris)

codegen(model)
} # }