sampling: Random sampling of data into train and test

Description Usage Arguments Value Author(s) Examples

View source: R/functions.R

Description

The function does random sampling of the data and split it into train and test datasets. Training base percentage and seed value(optional) is taken as arguments. If seed value is not specified, random seed will be generated on different iterations.

Usage

1
sampling(base, train_perc = 0.7, seed = NA, replace = F)

Arguments

base

input dataframe

train_perc

(optional) percentage of total base to be kept as training sample, to be provided as decimal/fraction (default percentage is 0.7)

seed

(optional) seed value (if not given random seed is generated)

replace

(optional) whether replacement will e with or without replacement (default is FALSE ie. without replacement)

Value

An object of class "sampling" is a list containing the following components:

train_sample

training sample as a dataframe

test_sample

test sample as a dataframe

seed

seed used

Author(s)

Arya Poddar <aryapoddar290990@gmail.com>

Examples

1
2
3
4
5
data <- iris
sampling_list <- sampling(base = data,train_perc = 0.7,seed = 1234)
sampling_list$train
sampling_list$test
sampling_list$seed

scorecardModelUtils documentation built on May 2, 2019, 9:59 a.m.