Description
The LinearRegressionPredict function takes a model built by the
Linear Regression (td_lin_reg_mle
) function and a test data set whose
input attributes are the same as those in the model, and predicts
the response variable for each observation in the test data set.
Usage
td_linreg_predict_mle (
object = NULL,
newdata = NULL,
accumulate = NULL,
input.columns = NULL,
newdata.sequence.column = NULL,
object.sequence.column = NULL,
newdata.order.column = NULL,
object.order.column = NULL
)
## S3 method for class 'td_lin_reg_mle'
predict(
object = NULL,
newdata = NULL,
accumulate = NULL,
input.columns = 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. |
accumulate |
Optional Argument. |
input.columns |
Optional Argument. |
newdata.sequence.column |
Optional Argument. |
object.sequence.column |
Optional Argument. |
Value
Function returns an object of class "td_linreg_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("linearregression_example", "housing_data")
# Create object(s) of class "tbl_teradata".
housing_data <- tbl(con, "housing_data")
# Build a linear regression model on the input data
td_lin_reg_out <- td_lin_reg_mle(data = housing_data,
formula = (sellingprice ~ housesize + lotsize
+ bedrooms + granite + upgradedbathroom)
)
# Example 1: This example uses the above linear regression model to
# make the predictions using td_linreg_predict_mle() function.
td_lin_reg_predict_out <- td_linreg_predict_mle(object = td_lin_reg_out$result,
newdata = housing_data)
# Alternatively use the generic S3 predict function to make prediction.
td_linreg_predict_out1 <- predict(object = td_lin_reg_out,
newdata = housing_data,
accumulate = c("housesize","lotsize","bedrooms",
"granite","upgradedbathroom"))
# Example 2: This example uses a persisted model to make predictions.
# Persist the model in the Vantage Advanced SQL Engine using the copy_to() function.
linregmodel <- td_lin_reg_out[[1]] %>% copy_to(con, df = .)
td_linreg_predict_out2 <- td_linreg_predict_mle(object = linregmodel,
newdata = housing_data
)