% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/nmfae.R
\name{predict.nmfae}
\alias{predict.nmfae}
\title{Predict method for nmfae objects}
\usage{
\method{predict}{nmfae}(object, newY2 = NULL, Y1 = NULL, type = c("response", "class"), ...)
}
\arguments{
\item{object}{An object of class \code{"nmfae"} returned by \code{\link{nmfae}}.}

\item{newY2}{Optional new input matrix (P2 x M) for prediction.
If \code{NULL}, returns in-sample fitted values.}

\item{Y1}{Optional actual output matrix for comparison plotting.}

\item{type}{Character. \code{"response"} (default) returns the predicted matrix.
\code{"class"} returns a factor of predicted class labels (row with max value).}

\item{...}{Not used.}
}
\value{
For \code{type = "response"}: a matrix of class \code{"predict.nmfae"}.
For \code{type = "class"}: a factor of class \code{"predict.nmfae"} with
predicted class labels. If \code{Y1} was provided, actual classes are stored
in \code{attr(result, "actual")}.
}
\description{
\code{predict.nmfae} computes fitted or predicted values from a three-layer NMF model.
Without \code{newY2}, returns the in-sample fitted values \eqn{X_1 \Theta X_2 Y_2}.
With \code{newY2}, computes out-of-sample predictions \eqn{X_1 \Theta X_2 \cdot \mathrm{newY2}}.

When \code{type = "class"}, each column is classified to the row with the
maximum predicted value (useful when \eqn{Y_1} is a one-hot class matrix
from \code{\link{nmfkc.class}}).

If \code{Y1} (actual values) is provided, it is stored as an attribute so that
\code{plot.predict.nmfae} can produce an observed-vs-predicted scatter plot
(for \code{type = "response"}) or a confusion matrix heatmap
(for \code{type = "class"}).
}
\examples{
\donttest{
set.seed(1)
Y <- matrix(runif(20), nrow = 4)
res <- nmfae(Y, rank = 2)
pred <- predict(res)
}
}
\seealso{
\code{\link{nmfae}}, \code{\link{plot.predict.nmfae}},
\code{\link{nmfkc.class}}
}
