Skip to content

Commit

Permalink
Improved codegen for tm workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
pinduzera committed Nov 13, 2024
1 parent 226cbc1 commit b188d1b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# sasctl (development version)

* Added `scr_batch` argument to `format_data_json`, allowing to have all data in a single json payload for Viya 2024.7 SCR batch scoring feature.
* Fixed some issues related to the PMML payload when uploading models to SAS Model Manager
* Fixed some issues related to the PMML payload when uploading models to SAS Model Manager in some SAS Viya versions
* Fixed `openBrowser` using a function instead of the argument.
* Improved `codegen` for Tidy Models workflows guessing the predictors from the pre processing pipeline instead of the model workflow recipe.

# sasctl 0.7.4

Expand Down
11 changes: 7 additions & 4 deletions R/codegen.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#'
#' @description
#'
#' \strong{EXPERIMENTAL STATE - MAY NO WORK AS INTENDED}
#' \strong{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.
Expand Down Expand Up @@ -154,15 +154,18 @@ codegen.glm <- function(model, path = "scoreCode.R", rds = "model.rds", cutoff =

codegen.workflow <- function(tm_workflow, path = "scoreCode.R", rds = "model.rds", inputs = NULL,
libs = c(), referenceLevel = NULL) {

predictors <- colnames(tm_workflow[["pre"]][["mold"]][["predictors"]])


if (!is.null(inputs)) {

if (!is.vector(names(hmeqTrain))) stop("inputs must be a vector names")

predictors <- inputs

} else {

predictorsTable <- tm_workflow[['pre']][['actions']][['recipe']][['recipe']][['var_info']]
predictors <- predictorsTable[predictorsTable$role == "predictor",][["variable"]]

}

target <- colnames(tm_workflow[["pre"]][["mold"]][["outcomes"]])
Expand Down
2 changes: 1 addition & 1 deletion man/codegen.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b188d1b

Please sign in to comment.