% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/train_test_split.R
\name{train_test_split}
\alias{train_test_split}
\title{Split data into training and test sets}
\usage{
train_test_split(X, y, test_size = 0.2, seed = NULL)
}
\arguments{
\item{X}{A matrix or data.frame of features.}

\item{y}{A vector of responses (numeric or factor). Must have the same
number of rows as \code{X}.}

\item{test_size}{Proportion of observations to use as the test set.
A number in (0, 1). Default is \code{0.2} (80/20 split).}

\item{seed}{An optional integer random seed for reproducibility. If
\code{NULL} (default) the current RNG state is used.}
}
\value{
A named list with four elements:
\item{X_train}{Training features (same type as \code{X}).}
\item{X_test}{Test features (same type as \code{X}).}
\item{y_train}{Training response.}
\item{y_test}{Test response.}
}
\description{
Randomly splits a feature matrix or data.frame and its corresponding
response vector into training and test subsets.
}
\examples{
# matrix input
X <- iris[, 1:4]
y <- iris$Species
d <- unifiedml::train_test_split(X, y, test_size = 0.3, seed = 42)
dim(d$X_train)  # 105 x 4
dim(d$X_test)   #  45 x 4

# data.frame input
d2 <- unifiedml::train_test_split(iris[, 1:4], iris$Species, test_size = 0.2)
is.data.frame(d2$X_train)  # TRUE

}
