Teradata R Package Function Reference | 17.00 - 17.00 - SVMDensePredict - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
17.00
created_date
September 2020
category
Programming Reference
featnum
B700-4007-090K

Description

The SVMDensePredict function takes the model output by the function SVMDense (td_svm_dense_mle) and a set of test samples in dense format and outputs a prediction for each sample.

Usage

  td_svm_dense_predict_mle (
      object = NULL,
      newdata = NULL,
      attribute.columns = NULL,
      sample.id.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.order.column = NULL,
      object.order.column = NULL
  )

  ## S3 method for class 'td_svm_dense_mle'
 predict(
      object = NULL,
      newdata = NULL,
      attribute.columns = NULL,
      sample.id.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.order.column = NULL,
      object.order.column = NULL
  )

Arguments

object

Required Argument.
Specifies the model tbl_teradata generated by td_svm_dense_mle.
This argument can accept either a tbl_teradata or an object of "td_svm_dense_mle" class.

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 input tbl_teradata containing the test data set.

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)

attribute.columns

Required Argument.
Specifies the input tbl_teradata columns that contain the attributes of the test samples. Attribute columns must be numeric (int, real, bigint, smallint, or float).
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.
Types: character

accumulate.label

Optional Argument.
Specifies the columns to be copied from the input tbl_teradata to the output tbl_teradata.
Types: character OR vector of Strings (character)

output.class.num

Optional Argument.
Only valid for multiple class models. If the value of this argument is k, the output tbl_teradata will include k class labels with corresponding predict_confidence instead of a single predicted result. The input value must be no less than 1.
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: integer

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.
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_dense_predict_mle" which is a named list containing object of class "tbl_teradata".
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("svmdense_example", "svm_iris_train")
    loadExampleData("svmdensepredict_example", "svm_iris_test")

    # Create object(s) of class "tbl_teradata".
    svm_iris_train <- tbl(con, "svm_iris_train")
    svm_iris_test <- tbl(con, "svm_iris_test")

    # Example 1 - Linear Model
    # Create the Model
    td_svm_dense_linear <- td_svm_dense_mle(data = svm_iris_train,
                                            sample.id.column = "id",
                                            attribute.columns = c('sepal_length', 'sepal_width', 
                                                                  'petal_length', 'petal_width'),
                                            kernel.function = "linear",
                                            label.column = "species",
                                            cost = 1,
                                            bias = 0,
                                            max.step = 100,
                                            seed = 1
                                           )

    # Run predict on the test data using the model generated
    td_svm_dense_predict_mle_out1 <- td_svm_dense_predict_mle(object = td_svm_dense_linear,
                                                newdata = svm_iris_test,
                                                attribute.columns=c('sepal_length','sepal_width',
                                                                    'petal_length','petal_width'),
                                                sample.id.column = "id",
                                                accumulate.label = c("id","species"),
                                                output.class.num = 2
                                                )

    # Example 2 - Polynomial Model
    # Create the Model
    td_svm_dense_polynomial <- td_svm_dense_mle(data = svm_iris_train,
                                              sample.id.column = "id",
                                              attribute.columns = c('sepal_length', 'sepal_width', 
                                                                    'petal_length', 'petal_width'),
                                              kernel.function = "polynomial",
                                              gamma = 0.1,
                                              degree = 2,
                                              subspace.dimension = 120,
                                              hash.bits = 512,
                                              label.column = "species",
                                              cost = 1,
                                              bias = 0,
                                              max.step = 100,
                                              seed = 1
                                             )

    # Run predict on the test data using the model generated
    td_svm_dense_predict_mle_out2 <- td_svm_dense_predict_mle(object = td_svm_dense_polynomial,
                                                newdata = svm_iris_test,
                                                attribute.columns=c('sepal_length','sepal_width',
                                                                    'petal_length','petal_width'),
                                                sample.id.column = "id",
                                                accumulate.label = c("id","species")
                                                )

    # Example 3 - Radial Basis Model (RBF) Model
    # Create the Model
    td_svm_dense_rbf <- td_svm_dense_mle(data = svm_iris_train,
                                         sample.id.column = "id",
                                         attribute.columns = c('sepal_length', 'sepal_width', 
                                                               'petal_length' , 'petal_width'),
                                         kernel.function = "rbf",
                                         gamma = 0.1,
                                         subspace.dimension = 120,
                                         hash.bits = 512,
                                         label.column = "species",
                                         cost = 1,
                                         bias = 0,
                                         max.step = 100,
                                         seed = 1
                                        )

    # Run predict on the test data using the model generated
    td_svm_dense_predict_mle_out3 <- td_svm_dense_predict_mle(object = td_svm_dense_rbf,
                                                newdata = svm_iris_test,
                                                attribute.columns=c('sepal_length','sepal_width',
                                                                    'petal_length','petal_width'),
                                                sample.id.column = "id",
                                                accumulate.label = c("id","species"),
                                                output.responses = c("setosa","virginica",
                                                                     "versicolor")
                                                )

    # Example 4 - Sigmoid Model
    # Create the Model
    td_svm_dense_sigmoid <- td_svm_dense_mle(data = svm_iris_train,
                                             sample.id.column = "id",
                                             attribute.columns = c('sepal_length', 'sepal_width', 
                                                                   'petal_length', 'petal_width'),
                                             kernel.function = "sigmoid",
                                             gamma = 0.1,
                                             subspace.dimension = 120,
                                             hash.bits = 512,
                                             label.column = "species",
                                             cost = 1,
                                             bias = 0,
                                             max.step = 30,
                                             seed = 1
                                            )

    # Run predict on the test data using the model generated
    td_svm_dense_predict_mle_out4 <- td_svm_dense_predict_mle(
                                              object = td_svm_dense_sigmoid$model.table,
                                              newdata = svm_iris_test,
                                              attribute.columns=c('sepal_length','sepal_width',
                                                                  'petal_length','petal_width'),
                                              sample.id.column = "id",
                                              accumulate.label = c("id","species"),
                                              output.responses = c("virginica")
                                             )

    # Example 5 - Alternatively use the predict S3 method for prediction
    predict_out_linear <- predict(td_svm_dense_linear,
                                  newdata = svm_iris_test,
                                  attribute.columns=c('sepal_length','sepal_width','petal_length',
                                                      'petal_width'),
                                  sample.id.column = "id",
                                  accumulate.label = c("id","species"),
                                  output.class.num = 2
                                 )