Description Usage Arguments Value Examples
View source: R/model_matrix_model.r
This function transforms new data based on transforming parameters from a ModelMatrixModel object
1 2 |
object |
a ModelMatrixModel object. |
data |
a data.frame. |
handleInvalid |
a string,'keep' or 'error'. In dummy variable transformation, if categorical variable has a factor level that is unseen before, 'keep' will keep the record, output dummy variables will be all zero. |
verbose |
boolean, if print out progress. |
... |
other parameters. |
A ModelMatrixModel class,which includes the transformed matrix and the necessary transforming parameters copied from input object.
1 2 3 4 5 6 7 8 9 | library(ModelMatrixModel)
traindf= data.frame(x1 = sample(LETTERS[1:5], replace = TRUE, 20),
x2 = rnorm(20, 100, 5),
y = rnorm(20, 10, 2))
newdf=data.frame(x1 = sample(LETTERS[1:5], replace = TRUE, 3),
x2 = rnorm(3, 100, 5))
mm=ModelMatrixModel(~x1+x2,traindf,remove_1st_dummy = FALSE)
mm_pred=predict(mm,newdf)
data.frame(as.matrix(head(mm_pred$x,2)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.