Teradata Package for R Function Reference | 17.00 - predict - 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
tdplyr: Model Predictions

Description

Generic predict function for performing predictions using results of model fitting functions, such as

  1. td_adaboost_mle()

  2. td_arima_mle()

  3. td_decision_forest_mle()

  4. td_decision_tree_mle()

  5. td_decision_tree_valib()

  6. td_glm_mle()

  7. td_glml1l2_mle()

  8. td_knn_recommender_mle()

  9. td_lin_reg_mle()

  10. td_lin_reg_valib()

  11. td_log_reg_valib()

  12. td_naivebayes_mle()

  13. td_naivebayes_textclassifier_mle()

  14. td_pca_valib()

  15. td_svm_sparse_mle()

  16. td_xgboost_mle()

This function invokes respective predict methods, based on the class of the the model (first argument).

Usage

  predict(object, ...)

Arguments

object

Required Argument.
Model object can be one of the following class:

  1. td_adaboost_mle

  2. td_glm_mle

  3. td_glml1l2_mle

  4. td_decision_forest_mle

  5. td_decision_tree_mle

  6. td_decision_tree_valib

  7. td_naivebayes_mle

  8. td_naivebayes_textclassifier_mle

  9. td_svm_sparse_mle

  10. td_svm_dense_mle

  11. td_arima_mle

  12. td_lar_mle

  13. td_lin_reg_valib

  14. td_log_reg_valib

  15. td_pca_valib

  16. td_xgboost_mle

  17. td_knn_recommender_mle

  18. td_lin_reg_mle

It is usually created using the following methods:

  1. td_adaboost_mle

  2. td_glm_mle

  3. td_glml1l2_mle

  4. td_decision_forest_mle

  5. td_decision_tree_mle

  6. td_decision_tree_valib

  7. td_naivebayes_mle

  8. td_naivebayes_textclassifier_mle

  9. td_svm_sparse_mle

  10. td_svm_dense_mle

  11. td_arima_mle

  12. td_lar_mle

  13. td_lin_reg_valib

  14. td_log_reg_valib

  15. td_pca_valib

  16. td_xgboost_mle

  17. td_knn_recommender_mle

  18. td_lin_reg_mle

...

Additional arguments useful for predictions.

Value

Return value from predict depends on the class of the object.

Examples

  
    # Please visit individual predict in-line documentation for more examples.
    # help(predict.td_adaboost_mle)
    # help(predict.td_glm_mle)
    # help(predict.td_glml1l2_mle)
    # help(predict.td_decision_forest_mle)
    # help(predict.td_decision_tree_mle)
    # help(predict.td_decision_tree_valib)
    # help(predict.td_lin_reg_valib)
    # help(predict.td_log_reg_valib)
    # help(predict.td_naivebayes_mle)
    # help(predict.td_naivebayes_textclassifier_mle)
    # help(predict.td_pca_valib)
    # help(predict.td_svm_sparse_mle)
    # help(predict.td_svm_dense_mle)
    # help(predict.td_arima_mle)

    
    #### GLM Predict Example ####
    # Get the current context/connection.
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("glm_example", "admissions_train")
    loadExampleData("glmpredict_example", "admissions_test")
    
    # Create remote tibble objects.
    admissions_test <- tbl(con, "admissions_test")
    admissions_train <- tbl(con, "admissions_train")
    
    # Example 1 -
    # First train the data, i.e., create a GLM Model
    td_glm_out <- 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
    )
    
    # Run predict on the output of GLM.
    glm_predict_out <- predict(td_glm_out,
                             newdata = admissions_test,
                             terms = c("id","masters","gpa","stats","programming","admitted"),
                             family = "LOGISTIC",
                             linkfunction = "LOGIT"
    )