Last data update: 2014.03.03
|
R: Training and validation samples from data
init_values | R Documentation |
Training and validation samples from data
Description
Draw training and test samples from data. Samples can be accessed by subsctioting original data or by their own references.
Usage
init_values(X, Y = NULL, sample.size = 0.5,
data.splitting = "ALL",
unit.scaling = FALSE,
scaling = FALSE,
regression = FALSE)
Arguments
X |
a matrix or dataframe to be splitted in training and validation sample
|
Y |
a response vector for the observed data.
|
sample.size |
size of the needed training sample in proportion of the nulber of observations in original data.
|
data.splitting |
not currently used.
|
unit.scaling |
if TRUE, scale all data in X between 0 and 1, if they are all positive, or between -1 and 1.
|
scaling |
if TRUE, centers and scales data, so each variable willhave mean 0 abd variance 1.
|
regression |
if TRUE and scaling = TRUE, Y will also be scaled.
|
Value
a list with the following components :
xtrain |
a matrix or data frame representing the training sample.
|
ytrain |
a response vector representing the training responses according to the training sample.
|
xtest |
a matrix or data frame representing the validation sample.
|
ytest |
a response vector representing the validation responses according to the validation sample.
|
train_idx |
subscripts of the training sample.
|
test_idx |
subscripts of the validation sample.
|
Author(s)
Saip Ciss saip.ciss@wanadoo.fr
Examples
data(iris)
Y <- iris$Species
X <- iris[,-which(colnames(iris) == "Species")]
trainingAndValidationsamples <- init_values(X, Y, sample.size = 0.5)
Xtrain = trainingAndValidationsamples$xtrain
Ytrain = trainingAndValidationsamples$ytrain
Xvalid = trainingAndValidationsamples$xtest
Yvalid = trainingAndValidationsamples$ytest
Results
|