dts: Create Train and Test Datasets

Description Usage Arguments Examples

Description

By using a Train Index, this function easily creates train and test datasets.

Usage

1
dts(x = "TrainIndex", df = ds, df_train = ds1, df_test = ds2)

Arguments

x

The Train Index variable indicating which observations belong to the train sample.

df

The entire data.

df_train

The desired name for the train dataset.

df_test

The desired name for the test dataset.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
set.seed(123)
TrainIndex <- createDataPartition(ds$t_Paid, p = 0.7,  # create a balanced partitions with respect to the target
                                  list = FALSE,       # change p for training data size
                                  times = 1)

ds$TrainIndex <- 0
ds$TrainIndex[TrainIndex] <- 1
dts(x = "TrainIndex", df = ds, df_train = ds1, df_test = ds2)

# 'ds' is the entire data
# 'ds1' is the chosen name for the train sample
# 'ds2' is the chosen name for the test sample

Ehsan-F/R-Mixtape documentation built on June 24, 2020, 12:22 a.m.