Description
The AdaBoostPredict function applies the model output by the
function AdaBoost (td_adaboost_mle
) to a new
data set, outputting predicted labels for each data point.
Usage
td_adaboost_predict_mle (
object = NULL,
newdata = NULL,
attr.groupby.columns = NULL,
attr.pid.columns = NULL,
attr.val.column = NULL,
output.response.probdist = FALSE,
accumulate = NULL,
output.responses = NULL,
newdata.sequence.column = NULL,
object.sequence.column = NULL,
newdata.partition.column = NULL,
newdata.order.column = NULL,
object.order.column = NULL)
## S3 method for class 'td_adaboost_mle'
predict(
object = NULL,
newdata = NULL,
attr.groupby.columns = NULL,
attr.pid.columns = NULL,
attr.val.column = NULL,
output.response.probdist = FALSE,
accumulate = NULL,
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. |
object.order.column |
Required Argument. |
newdata |
Required Argument. |
newdata.partition.column |
Required Argument. |
newdata.order.column |
Optional Argument. |
attr.groupby.columns |
Required Argument. |
attr.pid.columns |
Required Argument. |
attr.val.column |
Required Argument. |
output.response.probdist |
Optional Argument. |
accumulate |
Optional Argument. |
output.responses |
Optional Argument. |
newdata.sequence.column |
Optional Argument. |
object.sequence.column |
Optional Argument. |
Value
Function returns an object of class "td_adaboost_predict_mle" which
is a named list containing tbl_teradata 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 the data to run the example
loadExampleData("adaboost_example", "housing_train", "housing_cat", "housing_train_response",
"iris_attribute_train", "iris_response_train")
loadExampleData("adaboost_predict_example", "housing_test", "iris_attribute_test")
# Create object(s) of class "tbl_teradata".
housing_train <- tbl(con, "housing_train")
housing_cat <- tbl(con, "housing_cat")
housing_train_response <- tbl(con, "housing_train_response")
iris_attribute_train <- tbl(con, "iris_attribute_train")
iris_response_train <- tbl(con, "iris_response_train")
housing_test <- tbl(con, "housing_test")
iris_attribute_test <- tbl(con, "iris_attribute_test")
# Example 1 - This example uses test data and the model output by the td_adaboost_mle()
# to use real estate sales data to predict home style.
#
# First, we will have to run td_adaboost_mle() function on the input in sparse format.
# We run td_unpivot_mle() to create the input in sparse format.
td_unpivot_out1 <- td_unpivot_mle(data = housing_train,
unpivot = c("price", "lotsize", "bedrooms", "bathrms",
"stories","driveway", "recroom", "fullbase",
"gashw", "airco", "garagepl", "prefarea"),
accumulate = "sn")
td_adaboost_out1 <- td_adaboost_mle(attribute.data = td_unpivot_out1$result,
attribute.name.columns = "attribute",
attribute.value.column = "value_col",
categorical.attribute.data = housing_cat,
response.data = housing_train_response,
id.columns = "sn",
response.column = "response",
iter.num = 20,
num.splits = 10,
max.depth = 3,
min.node.size = 100)
# Use the generated model to predict the house style, on the test data.
# Transform the test data into sparse format.
td_unpivot_out2 <- td_unpivot_mle(data = housing_test,
unpivot = c("price", "lotsize", "bedrooms", "bathrms",
"stories","driveway", "recroom", "fullbase",
"gashw", "airco", "garagepl", "prefarea"),
accumulate = "sn")
td_adaboost_predict_out1 <- td_adaboost_predict_mle (object = td_adaboost_out1,
newdata = td_unpivot_out2$result,
attr.groupby.columns = 'attribute',
attr.pid.columns = 'sn',
attr.val.column = 'value_col',
newdata.partition.column = "sn",
object.order.column="classifier_id")
# Example 2 - In this example, we predict the 'species' for the flowers
# represented by the data points in the test data (iris_attribute_test) based on the
# model generated using td_adaboost_mle() function.
#
# Train an AdaBoost model on the input data which is in sparse format.
td_adaboost_out2 <- td_adaboost_mle(attribute.data = iris_attribute_train,
attribute.name.columns = "attribute",
attribute.value.column = "attrvalue",
response.data = iris_response_train,
id.columns = "pid",
response.column = "response",
iter.num = 5,
num.splits = 10,
max.depth = 3,
min.node.size = 5,
output.response.probdist=TRUE,
approx.splits=FALSE)
# Use the generated model to predict the species on the test data which is
# sparse format.
td_adaboost_predict_out2 <- td_adaboost_predict_mle (object = td_adaboost_out2,
newdata = iris_attribute_test,
attr.groupby.columns = 'attribute',
attr.pid.columns = 'pid',
attr.val.column = 'attrvalue',
newdata.partition.column = "pid",
output.response.probdist = TRUE,
output.responses = c('1','2','3'),
object.order.column="classifier_id")
# Using S3 predict function to predict the species on the test data based
# on the generated model 'td_adaboost_out2'.
td_adaboost_predict_out3 <- predict(object = td_adaboost_out2,
newdata = iris_attribute_test,
attr.groupby.columns = 'attribute',
attr.pid.columns = 'pid',
attr.val.column = 'attrvalue',
newdata.partition.column = "pid",
output.response.probdist = TRUE,
output.responses = c('1','2','3'),
object.order.column="classifier_id")