Teradata Package for R Function Reference | 17.20 - 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

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for R
Release Number
17.20
Published
March 2024
ft:locale
en-US
ft:lastEdition
2024-05-03
dita:id
TeradataR_FxRef_Enterprise_1720
lifecycle
latest
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()

  17. td_svm_dense_mle()

  18. td_decision_forest()

  19. td_glm()

  20. td_glm_per_segment()

  21. td_kmeans()

  22. td_naivebayes_textclassifier_trainer()

  23. td_one_class_svm()

  24. td_xgboost()

  25. td_svm()

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_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()

  17. td_svm_dense_mle()

  18. td_decision_forest()

  19. td_glm()

  20. td_glm_per_segment()

  21. td_kmeans()

  22. td_naivebayes_textclassifier_trainer()

  23. td_one_class_svm()

  24. td_xgboost()

  25. td_svm()

It is usually created using the following methods:

  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()

  17. td_svm_dense_mle()

  18. td_decision_forest()

  19. td_glm()

  20. td_glm_per_segment()

  21. td_kmeans()

  22. td_naivebayes_textclassifier_trainer()

  23. td_one_class_svm()

  24. td_xgboost()

  25. td_svm()

...

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"
    )