% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rTensor_Decomp.R
\name{twodlda}
\alias{twodlda}
\title{Two-Dimensional Linear Discriminant Analysis}
\usage{
twodlda(tnsr, labels = NULL, r_ranks = NULL, c_ranks = NULL,
  max_iter = 25, tol = 1e-05)
}
\arguments{
\item{tnsr}{3-Tensor where the third mode indexes observations}

\item{labels}{a vector of class labels (length must equal the third mode)}

\item{r_ranks}{number of left projection vectors (columns of \code{L})}

\item{c_ranks}{number of right projection vectors (columns of \code{R})}

\item{max_iter}{maximum number of iterations if error stays above \code{tol}}

\item{tol}{relative Frobenius norm error tolerance}
}
\value{
a list containing the following:\describe{
\item{\code{L}}{the left projection matrix of size \code{mode1} by \code{r_ranks}}
\item{\code{R}}{the right projection matrix of size \code{mode2} by \code{c_ranks}}
\item{\code{Z}}{a list of projected feature matrices (one per observation), each of size \code{r_ranks} by \code{c_ranks}}
\item{\code{conv}}{whether or not \code{resid} < \code{tol} by the last iteration}
\item{\code{est}}{estimate of \code{tnsr} after projection and back-projection}
\item{\code{norm_percent}}{the percent of Frobenius norm explained by the approximation}
\item{\code{fnorm_resid}}{the Frobenius norm of the error \code{fnorm(est-tnsr)}}
\item{\code{all_resids}}{vector containing the Frobenius norm of error for all the iterations}
}
}
\description{
Two-Dimensional Linear Discriminant Analysis (2DLDA) for a 3-Tensor of matrix observations with class labels. Finds left and right projection matrices \code{L} and \code{R} that maximize class separability in the projected space. Each frontal slice is treated as a matrix observation. This is an iterative algorithm. For more details on 2DLDA, consult Ye et al. (2005).
}
\details{
A progress bar is included to help monitor operations on large tensors. The input tensor must be 3-dimensional, where the third mode indexes the observations. Unlike other decompositions in this package, 2DLDA is a supervised method that requires class labels.
}
\note{
The length of \code{labels} must match the third mode of \code{tnsr}.
}
\examples{
tnsr <- rand_tensor(c(5,4,10))
labels <- rep(c(1,2), each=5)
twodldaD <- twodlda(tnsr, labels=labels, r_ranks=2, c_ranks=2)
twodldaD$conv
twodldaD$norm_percent
}
\references{
J. Ye, R. Janardan, Q. Li, "Two-Dimensional Linear Discriminant Analysis". Advances in Neural Information Processing Systems 2005.
}
\seealso{
\code{\link{mpca}}, \code{\link{tucker}}
}
