Learn R Programming

parallelSVM (version 0.1-9)

trainSample: Sample data in parallel

Description

Sample data or data and output in parallel: each core provides one sample of your desired size.

Usage

trainSample(x, y = NULL, numberCores = detectCores(), samplingSize = 0.2)

Arguments

x
A data frame, or structure convertable to a data frame, which you want to sample upon.
y
An vector containing a target variable for predictions later on. This target variable could be contained in x as well, then y is set to NULL.
numberCores
In this setting equal to number of different training samples you are creating: one for each core you are using.
samplingSize
Size of your training sample in percentage.

Value

If y is null, you get a list of length numberCores. Each core has created one item of your list, namely a data frame containing a a samplingSize size sample of x. If y is not null, again you get a list of length numberCores. Each core has created one item of your list, namely:
xSample
A data frame containing a samplingSize size sample of x.
ySample
A vector with the corresponding y values (corresponding indices with x).

See Also

Under the hood this function uses foreach, and sample

Examples

Run this code
## Not run: 
# # Create your data
# x <- data.frame(1:10,10:1)
# y <- 1:10
# 
# # Sampling with provided y
# trainSample(x,y,numberCores=2,samplingSize = 0.5)
# 
# # Sampling without provided y
# trainSample(x,numberCores=2,samplingSize = 0.5)
# ## End(Not run)

Run the code above in your browser using DataLab