Teradata Package for R Function Reference | 17.00 - SVMSparsePredict - 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
SparseSVMPredictor

Description

The SparseSVMPredictor function takes the model generated by the function SparseSVMTrainer (td_svm_sparse_mle) and a set of test samples (in sparse format) and outputs a prediction for each sample.

Usage

  td_svm_sparse_predict_sqle (
      object = NULL,
      newdata = NULL,
      sample.id.column = NULL,
      attribute.column = NULL,
      value.column = NULL,
      accumulate.label = NULL,
      output.class.num = 1,
      newdata.partition.column = NULL,
      newdata.order.column = NULL,
      object.order.column = NULL
  )
## S3 method for class 'td_svm_sparse_mle'
predict(
      object = NULL,
      newdata = NULL,
      sample.id.column = NULL,
      attribute.column = NULL,
      value.column = NULL,
      accumulate.label = NULL,
      output.class.num = 1,
      newdata.partition.column = NULL,
      newdata.order.column = NULL,
      object.order.column = NULL)

Arguments

object

Required Argument.
Specifies the model tbl_teradata generated by td_svm_sparse_mle.
This argument can accept either a tbl_teradata or an object of "td_svm_sparse_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 tbl_teradata 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 "newdata" column that contains the identifiers of the test samples. The "newdata" tbl_teradata must be partitioned by this column.
Types: character

attribute.column

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

value.column

Optional Argument.
Specifies the name of the "newdata" column that contains the attribute values. By default, each attribute has the value 1.
Types: character

accumulate.label

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

output.class.num

Optional Argument.
Specifies the number of class labels to appear in the output tbl_teradata, with its corresponding prediction confidence.
Note: This argument is valid only for multiple-class models.
Default Value: 1
Types: integer

Value

Function returns an object of class "td_svm_sparse_predict_sqle" which is a named list containing object of class "tbl_teradata".
Named list member can be referenced directly with the "$" operator using the 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 object(s) of class "tbl_teradata".
    svm_iris_input_train <- tbl(con, "svm_iris_input_train")
    svm_iris_input_test <- tbl(con, "svm_iris_input_test")
    
    # Example - 
    # Create the Sparse SVM model.
    svm_train <- 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
                                   )
    
    # Run predict on the output of td_svm_sparse_mle() function.
    svm_sparse_predict_result <- td_svm_sparse_predict_sqle(newdata = svm_iris_input_test,
                                                            newdata.partition.column = c("id"),
                                                            object = svm_train,
                                                            sample.id.column = "id",
                                                            attribute.column = "attribute",
                                                            value.column = "value1",
                                                            accumulate.label = c("species")
                                                            )
                                    
    # Alternatively use S3 predict on the output of td_svm_sparse_mle() to find prediction.
    predict_out <- predict(svm_train,
                           newdata = svm_iris_input_test,
                           newdata.partition.column = c("id"),
                           sample.id.column = "id",
                           attribute.column = "attribute",
                           value.column = "value1",
                           accumulate.label = c("species")
                           )