split_data: Split Data into Train and Test Partitions

View source: R/util.r

split_dataR Documentation

Split Data into Train and Test Partitions

Description

This function splits the input data and response variables into training and testing parts.

Usage

split_data(X, y, p.train = 0.7, n.train = round(nrow(X) * p.train))

Arguments

X

Input matrix, of dimension nobs by nvars; each row is an observation vector.

y

Vector of response variables.

p.train

Percentage of training set.

n.train

Number of cases for training; will override p.train if specified.

Value

List of training data x.tr, y.tr and testing data x.te, y.te.

Examples

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)
   

HTLR documentation built on Oct. 22, 2022, 5:05 p.m.