Description
The LinearRegressionPredict (td_linreg_predict_mle
) function takes a model
built by the Linear Regression 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 )
Arguments
object |
Required Argument. |
newdata |
Required 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 Teradata tbl 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 example data. loadExampleData("linearregression_example", "housing_data") # Create remote tibble objects. 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 to the Teradata 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 )