% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/predict.R
\name{predict.orthoMTL}
\alias{predict.orthoMTL}
\title{Predict from an orthoMTL Model}
\usage{
\method{predict}{orthoMTL}(object, newdata, type = c("link", "response", "class"), ...)
}
\arguments{
\item{object}{A fitted model object of class \code{"orthoMTL"}.}

\item{newdata}{A numeric matrix of new observations with dimensions
\code{n_new x p}. Column names are used for feature alignment if
available in the fitted object.}

\item{type}{Character; scale of the returned predictions. One of:
\describe{
  \item{\code{"link"}}{(default) the raw linear predictor
    \eqn{X B} (after the survival monotonicity projection, if
    applicable). Preserves the historical behaviour.}
  \item{\code{"response"}}{for \code{logistic} fits, the sigmoid
    \eqn{1 / (1 + e^{-XB})} giving \eqn{P(Y = +1)}; for non-logistic
    fits identical to \code{"link"}.}
  \item{\code{"class"}}{for \code{logistic} fits, the predicted
    class label in \eqn{\{-1, +1\}} (\code{sign(XB)}, with 0 mapped
    to \code{+1}). Errors for non-logistic fits.}
}}

\item{...}{Additional arguments (currently ignored).}
}
\value{
A numeric matrix of predictions with dimensions
  \code{n_new x n_tasks}. Column names correspond to task names
  if available.
}
\description{
Generate predictions from a fitted \code{orthoMTL} model for new
observations. In survival mode, predictions are projected onto the
non-negative non-increasing space to ensure monotonicity across tasks.
}
\details{
If the fitted object contains \code{feature_names} (i.e., the training
matrix \code{X} had column names), \code{newdata} columns are aligned
to match. Missing features cause an error. Extra features trigger a
warning and are dropped.

In survival mode (\code{object$hyperparameters$survival == TRUE}),
each row of the raw prediction matrix is projected via
\code{nnmaxheap_C()} to enforce non-negative, non-increasing values
across tasks (time thresholds).
}
\examples{
set.seed(42)
n <- 100; p <- 10; n_tasks <- 3
X <- matrix(rnorm(n * p), n, p)
colnames(X) <- paste0("V", seq_len(p))
W_true <- qr.Q(qr(matrix(rnorm(p * n_tasks), p, n_tasks)))
Y <- X \%*\% W_true + matrix(rnorm(n * n_tasks), n) * 0.1
K <- matrix(1, n_tasks, n_tasks); diag(K) <- 0.5
fit <- orthoMTL(X, Y, lambda = 1e-3, K = K, disjoint = FALSE)

X_new <- matrix(rnorm(20 * p), 20, p)
colnames(X_new) <- paste0("V", seq_len(p))
preds <- predict(fit, newdata = X_new)
dim(preds)
}
\references{
Vervier, K., Mahe, P., d'Aspremont, A., Veyrieras, J.-B., and
Vert, J.-P. (2014). On Learning Matrices with Orthogonal Columns
or Disjoint Supports. \emph{ECML-PKDD 2014}.
\url{https://hal.science/hal-00985654}
}
