Description
The DecisionForestPredict function uses the model generated by
the DecisionForest (td_decision_forest_mle
)
function to generate predictions on a response variable for a test set of data.
Note: This function is only available when tdplyr is connected to Vantage 1.1
or later versions.
Usage
td_decision_forest_predict_mle (
object = NULL,
newdata = NULL,
id.column = NULL,
detailed = FALSE,
terms = NULL,
output.response.probdist = FALSE,
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. |
id.column |
Required Argument. |
detailed |
Optional Argument. |
terms |
Optional Argument. |
output.response.probdist |
Optional Argument. |
output.responses |
Optional Argument.
Default Value: NULL |
newdata.sequence.column |
Optional Argument. |
object.sequence.column |
Optional Argument. |
Value
Function returns an object of class "td_decision_forest_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("decisionforestpredict_example", "housing_test", "housing_train")
# Create object(s) of class "tbl_teradata".
housing_train <- tbl(con, "housing_train")
housing_test <- tbl(con, "housing_test")
# Example 1 - Using model object generated by td_decision_forest_mle() function.
# Generate DecisionForest model based on train data "housing_train".
formula <- (homestyle ~ driveway + recroom + fullbase + gashw + airco + prefarea +
price + lotsize + bedrooms + bathrms + stories + garagepl)
decision_forest_model <- td_decision_forest_mle(data=housing_train,
formula = formula,
tree.type="classification",
ntree=50,
tree.size=100,
nodesize=1,
variance=0,
max.depth=12,
maxnum.categorical=20,
mtry=3,
mtry.seed=100,
seed=100
)
# Use the generated model to predict the 'homestyle' on the test data housing_test.
df_predict_mle_out1 <- td_decision_forest_predict_mle(object = decision_forest_model,
newdata = housing_test,
id.column = "sn",
detailed = FALSE,
terms = c("homestyle")
)
# Example 2 - Using tbl_teradata object of the model generated by td_decision_forest_mle()
# function.
# Use 'predictive.model' tbl_teradata of the generated model (in Example 1) to predict
# the 'homestyle' on the test data housing_test.
df_predict_mle_out2 <- td_decision_forest_predict_mle(
object = decision_forest_model$predictive.model,
newdata = housing_test,
id.column = "sn",
detailed = FALSE,
terms = c("homestyle")
)
# Example 3 - Use the generated model to predict the probabilities for 'homestyle' on the
# test data 'housing_test' of each sample.
df_predict_mle_out1 <- td_decision_forest_predict_mle(object = decision_forest_model,
newdata = housing_test,
id.column = "sn",
detailed = FALSE,
output.response.probdist=TRUE,
terms = c("homestyle")
)
# Example 4 - Use the generated model to predict 'homestyle' in the test data 'housing_test'
# and probabilities of each label specified in the "output.response" argument. When
# "output.responses" is used, "output.response.probdist" argument must be set to TRUE to
# get probability values.
df_predict_mle_out1 <-td_decision_forest_predict_mle(object = decision_forest_model,
newdata = housing_test,
id.column = "sn",
detailed = FALSE,
output.response.probdist = TRUE,
output.responses = c('Eclectic','Classic','bungalow'),
terms = c("homestyle")
)