powered by
This function splits the input data and response variables into training and testing parts.
split_data(X, y, p.train = 0.7, n.train = round(nrow(X) * p.train))
List of training data x.tr, y.tr and testing data x.te, y.te.
x.tr
y.tr
x.te
y.te
Input matrix, of dimension nobs by nvars; each row is an observation vector.
nobs
nvars
Vector of response variables.
Percentage of training set.
Number of cases for training; will override p.train if specified.
p.train
dat <- gendata_MLR(n = 100, p = 10) dat <- split_data(dat$X, dat$y, p.train = 0.7) dim(dat$x.tr) dim(dat$x.te)
Run the code above in your browser using DataLab