createTestAndTrainSamples: Create test and train samples

Description Usage Arguments Value Author(s) Examples

View source: R/createTestAndTrainSamples.R

Description

This function creates train and test datasets given a database and the Y variable.

Usage

1
2
createTestAndTrainSamples(dataset, yvar, seed = 12345,
  percentage = 0.7)

Arguments

dataset

The dataset you want to split into test and train samples.

yvar

The Y variable in your dataset.

seed

The seed number used to generate the train and test samples. The default value is 12345.

percentage

The percentage of data that goes to training sample. The default value is 0.7.

Value

An object list with the train dataset, test dataset and the proportions.

Author(s)

Rodrigo Gonçalves and Leandro Daniel

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
base = loansdefaulters
mydataset <- createTestAndTrainSamples(dataset = base, 
                                       yvar = "y_loan_defaulter", 
                                       seed = 12345, 
                                       percentage = 0.7)
# or
mydataset <- createTestAndTrainSamples(dataset = base, yvar = "y_loan_defaulter")
# to use the final samples and to see the proportion
mydataset$data.train
mydataset$data.test
mydataset$event.proportion

ldaniel/fgvr documentation built on June 9, 2020, 10:11 a.m.