% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pptr.R
\name{pptr}
\alias{pptr}
\title{Trains a Projection-Pursuit oblique decision tree.}
\usage{
pptr(
  formula = NULL,
  data = NULL,
  x = NULL,
  y = NULL,
  mode = NULL,
  lambda = 0.5,
  seed = NULL,
  pp = NULL,
  cutpoint = NULL,
  stop = NULL,
  binarize = NULL,
  grouping = NULL,
  leaf = NULL
)
}
\arguments{
\item{formula}{A formula of the form \code{y ~ x1 + x2 + ...}, where \code{y} is a vector of labels and \code{x1}, \code{x2}, ... are the features.}

\item{data}{A data frame containing the variables in the formula.}

\item{x}{A matrix containing the features for each observation.}

\item{y}{A matrix containing the labels for each observation.}

\item{mode}{Training mode: either \code{"classification"} or \code{"regression"}. When \code{NULL} (default), mode is auto-detected from \code{y}'s type — factor or character vectors trigger classification, numeric vectors trigger regression. Setting it explicitly is useful for the binary-integer-labels case (\code{mode = "classification"} with integer 0/1 labels) and for failing fast on a type mismatch (\code{mode = "regression"} with a factor \code{y} errors immediately).}

\item{lambda}{A regularization parameter (default: 0.5). If \code{lambda = 0}, the model is trained using Linear Discriminant Analysis (LDA). If \code{lambda > 0}, the model is trained using Penalized Discriminant Analysis (PDA). The default uses PDA because pure LDA (\code{lambda = 0}) is ill-conditioned when there are more variables than effective observations (see the "Known limitations" section of the README). Cannot be used together with \code{pp}.}

\item{seed}{An optional integer seed for reproducibility. If \code{NULL} (default), a seed is drawn from R's RNG, so \code{set.seed()} controls reproducibility. If an integer is provided, that value is used directly.}

\item{pp}{A projection pursuit strategy object created by \code{\link{pp_pda}}. Cannot be used together with \code{lambda}.}

\item{cutpoint}{A split cutpoint strategy object created by \code{\link{cutpoint_mean_of_means}} (default).}

\item{stop}{A stopping rule object. Default depends on mode:
\code{\link{stop_pure_node}()} for classification, and
\code{stop_any(stop_min_size(5), stop_min_variance(0.01))} for regression.}

\item{binarize}{A binarization strategy object. Default depends on mode:
\code{\link{binarize_largest_gap}()} for classification, and
\code{\link{binarize_disabled}()} for regression (regression's default
grouping always yields a 2-group partition, so no binarization is needed).}

\item{grouping}{A grouping strategy object. Default depends on mode:
\code{\link{grouping_by_label}()} for classification, and
\code{\link{grouping_by_cutpoint}()} for regression.}

\item{leaf}{A leaf strategy object. Default depends on mode:
\code{\link{leaf_majority_vote}()} for classification, and
\code{\link{leaf_mean_response}()} for regression.}
}
\value{
A \code{pptr} model. Its S3 class vector is
  \code{c("pptr_classification", "pptr", "ppmodel")} or
  \code{c("pptr_regression", "pptr", "ppmodel")} depending on the mode.
}
\description{
This function trains a Projection-Pursuit oblique decision tree using either a formula and data frame interface or a matrix-based interface. When using the formula interface, specify the model formula and the data frame containing the variables. For the matrix-based interface, provide matrices for the features and labels directly.
If \code{lambda = 0}, the model is trained using Linear Discriminant Analysis (LDA). If \code{lambda > 0}, the model is trained using Penalized Discriminant Analysis (PDA).
}
\details{
Mode is taken from the \code{mode} argument when explicit, and otherwise auto-detected from `y` (factor/character → classification, numeric → regression). Pass \code{mode = "classification"} to force classification on integer labels (e.g. binary 0/1), or \code{mode = "regression"} to assert intent on numeric responses.
}
\examples{

# Example 1: formula interface with the `iris` dataset
pptr(Species ~ ., data = iris)

# Example 2: formula interface with the `iris` dataset with regularization
pptr(Species ~ ., data = iris, lambda = 0.5)

# Example 3: matrix interface with the `iris` dataset
pptr(x = iris[, 1:4], y = iris[, 5])

}
\seealso{
\code{\link{predict.pptr_classification}}, \code{\link{predict.pptr_regression}}, \code{\link{formula.ppmodel}}, \code{\link{print.pptr}}, \code{\link{save_json}}, \code{\link{load_json}}, \code{\link{pp_tree}} for parsnip integration
}
