The td_retrieve_model() function allows a user to recreate a tdplyr analytic function object from the information saved with the Model Catalog using td_save_model(). This analytic function object can then be used in the user’s workflow.
For example, if a user has built a user-base classification model, he or she can save the information related to this model and reuse it at every instance when there is need to score a new set of user data.
The td_retrieve_model() function can be used to retrieve only those models that are accessible to the requesting user.
See td_publish_model() for information on granting access to a model to other users.
Required arguments:
name specifies the name of the model to be retrieved.
Example Prerequisites
Follow the steps in td_save_model() to create and save a model.Example
- 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" )
- Print the scoring results.
> print(td_glm_predict_out1) ############ result ############ # Source: SQL [?? x 1] # Database: [Teradata 16.20.50.01] [Teradata Native Driver 16.20.0.35] [ALICE@Vantage1025/ALICE] # Groups: id masters gpa stats programming admitted fitted_value <int> <chr> <dbl> <chr> <chr> <int> <dbl> 1 66 no 3.87 Novice Beginner 1 0.755 2 65 yes 3.9 Advanced Advanced 1 0.653 3 63 no 3.83 Advanced Advanced 1 0.946 4 61 yes 4 Advanced Advanced 1 0.651 5 58 no 3.13 Advanced Advanced 1 0.950 6 56 no 3.82 Advanced Advanced 1 0.946 7 57 no 3.71 Advanced Advanced 1 0.946 8 60 no 4 Advanced Novice 1 0.865 9 64 yes 3.81 Advanced Advanced 1 0.656 10 68 no 1.87 Advanced Novice 1 0.891 # ... with more rows