same_shape {dataPreparation}R Documentation

Give same shape


Transform data_set into the same shape as reference_set. Espacially this function will be usefull to make your test set have the same shape as your train set.


same_shape(data_set, reference_set, verbose = TRUE)



Matrix, data.frame or data.table to transform


Matrix, data.frame or data.table


Should the algorithm talk? (logical, default to TRUE)


This function will make sure that data_set and reference_set

You should always use this function before applying your model on a new data set to make sure that everything will go smoothly. But if this function change a lot of stuff you should have a look to your preparation process, there might be something wrong.


Return data_set transformed in order to make it have the same shape as reference_set


## Not run: 
# Build a train and a test
train <- messy_adult
test <- adult # So test will have missing columns

# Prepare them
train <- prepare_set(train, verbose = FALSE, key = "country")
test <- prepare_set(test, verbose = FALSE, key = "country")

# Give them the same shape
test <- same_shape(test, train)
# As one can see in log, a lot of small change had to be done.
# This is an extreme case but you get the idea.

## End(Not run)
# "##NOT RUN:" mean that this example hasn't been run on CRAN since its long. But you can run it!

[Package dataPreparation version 1.0.4 Index]