Registers a zip formatted model in SAS Model Manager.

register_model(
  session,
  file,
  name,
  project,
  type,
  force_pmml_translation = TRUE,
  exact = TRUE,
  force = FALSE,
  model_function = NULL,
  additional_project_parameters = NULL,
  version = "latest",
  project_description = "R SASctl automatic project",
  ...
)

Arguments

session

viya_connection object, obtained through session function

file

path to file to be uploaded

name

model name that will be used when registering

project

MMproject object, project ID or project name. If name, will try to find a single project with exact name match. See exact parameter

type

string, pmml, spk, zip or astore

force_pmml_translation

default is TRUE, set to false will upload pmml as is, but may not work properly. Only if type = "pmml"

exact

the filter query should use "contains" for partial match or "eq" for exact match

force

Boolean, force the creation of project if unavailable

model_function

create_project() parameter of project model function of the created project if force = TRUE. Valid values: analytical, classification, cluster, forecasting, prediction, Text categorization, Text extraction, Text sentiment, Text topics, transformation

additional_project_parameters

list of additional parameters to be passed to create_project() additional_parameters parameter

version

This parameter indicates to create a new project version, use the latest version, or use an existing version to import the model into. Valid values are 'NEW', 'LATEST', or a number.

project_description

description string of additional parameters to be passed to create_project() description parameter

...

pass to sasctl::vPOST() function

Value

a MMmodel class list

Examples


if (FALSE) { # \dontrun{
### Building and registering a pmml model

library("pmml")

hmeq <- read.csv("https://support.sas.com/documentation/onlinedoc/viya/exampledatasets/hmeq.csv",
                 stringsAsFactors = TRUE)

hmeq <- na.omit(hmeq)

model1 <- lm(BAD ~ ., hmeq)


saveXML(pmml(model1, model.name="General_Regression_Model",
             app.name="Rattle/PMML",
             description="Linear Regression Model"),
             "my_model.pmml")
        
output <- register_model(session = sess,
                        file = "my_model.pmml",
                        name = "R_LinearModel",
                        type = "pmml", 
                         ## Project UUID example
                        projectId = "2322da44-9b24-43f6-96f4-456456231")

output

### Bulding and registering an astore model with SWAT

library("swat")

conn <- swat::CAS(hostname = "https://my.sas.server", ## change if needed
            port = 8777,
            username = "sasuser",
            password = "!s3cr3t")

swat::loadActionSet(conn, "astore")
swat::loadActionSet(conn, "decisionTree")


hmeq <- read.csv("https://support.sas.com/documentation/onlinedoc/viya/exampledatasets/hmeq.csv")
castbl <- cas.upload.frame(conn, hmeq)

colinfo <- cas.table.columnInfo(conn, table = castbl)$ColumnInfo
target <- colinfo$Column[1]
inputs <- colinfo$Column[-1]
nominals <- c(target, subset(colinfo, Type == 'varchar')$Column)

dt <- cas.decisionTree.dtreeTrain(conn,
                                  table = castbl,
                                  target = target,
                                  inputs = inputs,
                                  nominals = nominals,
                                  varImp = TRUE,
                                  ## save astore
                                  saveState = list(name = "dt_model_astore",
                                                   replace = TRUE), 
                                  casOut = list(name = 'dt_model', 
                                                replace = TRUE)
)
dt

## downloading astore
astore_blob <- cas.astore.download(conn,
                                   rstore =  list(name = "dt_model_astore")
)

## saving astore as binary file
astore_path <- "./rf_model.astore"
con <- file(astore_path, "wb")
### file is downloaded as base64 encoded
writeBin(object = jsonlite::base64_dec(astore_blob$blob$data), 
         con = con, useBytes = T)
         
close(con)

### sasctl connecting
sess <- session(hostname = "https://my.sas.server",
                username = "sasuser",
                password = "!s3cr3t")

output <- register_model(session = sess,
                          file = astore_path,
                          name = "R_swatModel",
                          type = "astore",
                          projectId = "a0c2923b-67e9-4e7f-b5d0-549a04103523") 

### Registering a Zip model

output <- register_model(session = sess,
                        file = "model.zip",
                        name = "R_LinearModel", 
                        type = "zip",
                        projectId = "2322da44-9b24-43f6-96f4-456456231") 

output
} # }