Similar to other predict methods, this function predicts fitted values from a fitted "LinearRegression" object.

# S3 method for LinearRegression
predict(model, data, key, features = NULL, model.format = NULL, ...)

Arguments

model

R6Class object
A "LinearRegression" object for prediction.

data

DataFrame
DataFrame containting the data.

key

character
Name of the ID column.

features

character of list of characters, optional
Name of feature columns for prediction.
If not provided, it defaults to all non-key columns of data.

model.format

character, optional
Choose the format of mdoel. "coefficients" or "pmml".
Defaults to "coefficients".

...

Reserved parameter.

Format

S3 methods

Value

Predicted values are returned as a DataFrame, structured as follows.

  • ID column, with same name and type as data's ID column.

  • VALUE, type DOUBLE, representing predicted values.

Examples

Perform the predict on DataFrame data2 using "LinearRegression" object lr:

>data2$Collect()
   ID     X1 X2  X3
1   0  1.690  B   1
2   1  0.054  B   2
3   2  0.123  A   2
4   3  1.980  A   1
5   4  0.563  A   1

Call the function and obtain the result:

>fitted <- predict(model = lr, data = data2, key = "ID")$Collect()
   ID      VALUE
1   0  10.314760
2   1   1.685926
3   2  -7.409561
4   3   2.021592
5   4  -3.122685

See also