Teradata Package for R Function Reference | 17.00 - td_retrieve_model - Teradata Package for R - Look here for syntax, methods and examples for the functions included in the Teradata Package for R.

Teradata® Package for R Function Reference

Product
Teradata Package for R
Release Number
17.00
Published
July 2021
Language
English (United States)
Last Update
2023-08-08
dita:id
B700-4007
NMT
no
Product Category
Teradata Vantage
td_retrieve_model

Description

Function to retrieve a saved model accessible to the current user.

Usage

td_retrieve_model(name)

Arguments

name

Required Argument.
Specifies the name of the saved model to be retrieved.
Types: character

Value

Object of class "td_analytics" corresponding to the model retrieved.

Examples


# Get remote data source connection.
con <- td_get_context()$connection

# Load example data.
loadExampleData("glm_example", "admissions_train")

# Create object of class "tbl_teradata" to use as input.
admissions_train <- tbl(con, "admissions_train")

# Create the GLM model.
td_glm_out1 <- td_glm_mle(formula = (admitted ~ stats + masters + gpa + programming),
                          family = "LOGISTIC",
                          linkfunction = "LOGIT",
                          data = admissions_train,
                          weights = "1",
                          threshold = 0.01,
                          maxit = 25,
                          step = FALSE,
                          intercept = TRUE
)

# Save this generated model.
td_save_model(model = td_glm_out1, name = "glm_model", description = "GLM test")

# Retrieve the saved model.
retrieved_glm_model <- td_retrieve_model("glm_model")

# Use the retrieved model for scoring.
loadExampleData("glmpredict_example", "admissions_test")
admissions_test <- tbl(con, "admissions_test")

td_glm_predict_out1 <- td_glm_predict_sqle(modeldata = retrieved_glm_model,
                                           newdata = admissions_test,
                                           terms = c("id","masters","gpa","stats",
                                                     "programming","admitted"),
                                           family = "LOGISTIC",
                                           linkfunction = "LOGIT"
                                           )