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. |
object.order.column |
Optional Argument. |
newdata |
Required Argument. |
newdata.order.column |
Optional Argument. |
attribute.columns |
Required Argument. |
sample.id.column |
Required Argument. |
accumulate.label |
Optional Argument. |
output.class.num |
Optional Argument.
Types: integer |
output.response.probdist |
Optional Argument. |
output.responses |
Optional Argument.
Types: character OR vector of characters |
newdata.sequence.column |
Optional Argument. |
object.sequence.column |
Optional Argument. |
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
)