predict.LinearRegression.Rd
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, ...)
S3
methods
R6Class object
A "LinearRegression" object for prediction.
DataFrame
DataFrame containting the data.
character
Name of the ID column.
character of list of characters, optional
Name of feature columns for prediction.
If not provided, it defaults to all non-key columns of data.
Reserved parameter.
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.
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