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

Teradata® R Package Function Reference

Product
Teradata R Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-02-28
dita:id
B700-4007
lifecycle
previous
Product Category
Teradata Vantage

Description

The SVMSparsePredict (td_svm_sparse_predict_mle) function takes the model output by the function SVMSparse (td_svm_sparse_mle) and a set of test samples (in sparse format) and outputs a prediction for each sample.
Note: This function is only available when tdplyr is connected to Vantage 1.1 or later versions.

Usage

  td_svm_sparse_predict_mle (
      object = NULL,
      newdata = NULL,
      sample.id.column = NULL,
      attribute.column = NULL,
      value.column = NULL,
      accumulate.label = NULL,
      output.class.num = NULL,
      output.response.probdist = TRUE,
      output.responses = NULL,
      newdata.sequence.column = NULL,
      object.sequence.column = NULL,
      newdata.partition.column = NULL,
      newdata.order.column = NULL,
      object.order.column = NULL
  )

Arguments

object

Required Argument.
Specifies the model tbl_teradata object generated by SVMSparse (td_svm_sparse_mle) function.

object.order.column

Optional Argument.
Specifies Order By columns for object.
Values to this argument can be provided as a vector, if multiple columns are used for ordering.
Types: character OR vector of Strings (character)

newdata

Required Argument.
Specifies the tbl_teradata object containing the input test data.

newdata.partition.column

Required Argument.
Specifies Partition By columns for newdata.
Values to this argument can be provided as a vector, if multiple columns are used for partition.
Types: character OR vector of Strings (character)

newdata.order.column

Optional Argument.
Specifies Order By columns for newdata.
Values to this argument can be provided as a vector, if multiple columns are used for ordering.
Types: character OR vector of Strings (character)

sample.id.column

Required Argument.
Specifies the name of the input tbl_teradata column that contains the identifiers of the test samples. The input tbl_teradata 'newdata' must be partitioned by this column.
Types: character

attribute.column

Required Argument.
Specifies the name of the input tbl_teradata column that contains the attributes of the test samples.
Types: character

value.column

Optional Argument.
Specifies the name of the input tbl_teradata column that contains the attribute values.
Default Value: "1"
Types: character

accumulate.label

Optional Argument.
Specifies the names of the input tbl_teradata columns to copy to the output table.
Types: character OR vector of Strings (character)

output.class.num

Optional Argument.
Valid only for multiple-class models. Specifies the number of class labels to appear in the output table, with its corresponding prediction confidence.
Note:

  1. With Vantage version prior to 1.1.1, the argument defaults to the value 1.

  2. output.class.num cannot be specified along with output.responses.

Types: numeric

output.response.probdist

Optional Argument.
Specifies whether to display output probability for the predicted category.
Note: output.response.probdist argument support is only available when tdplyr is connected to Vantage 1.1.1 or later versions.
Default Value: TRUE
Types: logical

output.responses

Optional Argument.
Specifies responses in the input tbl_teradata object.
Note:

  1. output.responses argument support is only available when tdplyr is connected to Vantage 1.1.1 or later versions.

  2. output.responses cannot be specified along with output.class.num.

  3. The argument output.response.probdist must be set to TRUE to use this argument.

Types: character OR vector of characters

newdata.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "newdata". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.
Types: character OR vector of Strings (character)

object.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "object". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.
Types: character OR vector of Strings (character)

Value

Function returns an object of class "td_svm_sparse_predict_mle" which is a named list containing Teradata tbl object.
Named list member can be referenced directly with the "$" operator using name: result.

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("svmsparsepredict_example", "svm_iris_input_test", "svm_iris_input_train")
    
    # Create remote tibble objects.
    svm_iris_input_train <- tbl(con, "svm_iris_input_train")
    svm_iris_input_test <- tbl(con, "svm_iris_input_test")
    
    # Example 1 - 
    # Generate SparseSVMTrainer model based on train data "svm_iris_input_train".
    svm_iris_model <- td_svm_sparse_mle(data = svm_iris_input_train,
                                        sample.id.column = "id",
                                        attribute.column = "attribute",
                                        value.column = "value1",
                                        label.column = "species",
                                        max.step = 150,
                                        seed = 0
                                        )
    
    # Use the generated model to predict the 'species' on the test data svm_iris_input_test.
    td_svm_sparse_predict_mle_out <- td_svm_sparse_predict_mle( object = svm_iris_model, 
                                                                newdata = svm_iris_input_test, 
                                                                newdata.partition.column = c("id"),
                                                                attribute.column = "attribute",
                                                                sample.id.column = "id",
                                                                value.column = "value1",
                                                                accumulate.label = "species"
                                                                )