Description
The LARPredict function takes new data and the model generated by
the function LAR (td_lar_mle
) and uses the predictors in
the model to output predictions for the new data.
Usage
td_lar_predict_mle (
object = NULL,
newdata = NULL,
mode = "STEP",
s = NULL,
target.col = NULL,
object.sequence.column = NULL,
newdata.sequence.column = NULL,
newdata.order.column = NULL,
object.order.column = NULL
)
## S3 method for class 'td_lar_mle'
predict(
object = NULL,
newdata = NULL,
mode = "STEP",
s = NULL,
target.col = NULL,
object.sequence.column = NULL,
newdata.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. |
mode |
Optional Argument.
|
s |
Optional Argument. |
target.col |
Optional Argument. |
newdata.sequence.column |
Optional Argument. |
object.sequence.column |
Optional Argument. |
Value
Function returns an object of class "td_lar_predict_mle" 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("larpredict_example", "diabetes_test", "diabetes")
# Create object(s) of class "tbl_teradata".
diabetes_test <- tbl(con, "diabetes_test")
diabetes <- tbl(con, "diabetes") %>% rename_all(tolower)
# Build a LAR model with response variable 'y' and ten baseline predictors.
td_lar_out <- td_lar_mle(formula = (y ~ hdl + glu + ldl + map1 + sex + tch + age + ltg
+ bmi + tc),
data = diabetes,
type = "LAR",
max.steps = 20,
intercept = TRUE
)
# Example 1: Use the model object directly as input to the td_lar_predict_mle() function.
td_lar_predict_out1 <- td_lar_predict_mle(object = td_lar_out,
newdata = diabetes_test,
mode = "step",
s = 1.6,
target.col = c("y")
)
# Example 2: Alternatively use the predict S3 method to find predictions.
predict_out <- predict(td_lar_out,
newdata = diabetes_test,
mode = "step",
s = 1.6,
target.col = c("y")
)
# Example 3: Use the tbl_teradata from a previously created model
# Extract the model tbl_teradata using the extract2() function
td_lar_out_tbl <- td_lar_out %>% extract2(1)
td_lar_predict_out2 <- td_lar_predict_mle(object = td_lar_out_tbl,
newdata = diabetes_test,
mode = "step",
s = 1.6,
target.col = c("y")
)
# The prediction result can be persisted in a table - "result_td_lar_predict_out2".
copy_to(con,
df = td_lar_predict_out2$result,
name = "result_td_lar_predict_out2",
overwrite = TRUE)