same_shape {dataPreparation}R Documentation

Give same shape

Description

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

Usage

same_shape(data_set, reference_set, verbose = TRUE)

Arguments

data_set

Matrix, data.frame or data.table to transform

reference_set

Matrix, data.frame or data.table

verbose

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

Details

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.

Value

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

Examples

## Not run: 
# Build a train and a test
data(tiny_messy_adult)
data(adult)
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.1.1 Index]