predict.orthoMTL: Predict from an orthoMTL Model

View source: R/predict.R

predict.orthoMTLR Documentation

Predict from an orthoMTL Model

Description

Generate predictions from a fitted orthoMTL model for new observations. In survival mode, predictions are projected onto the non-negative non-increasing space to ensure monotonicity across tasks.

Usage

## S3 method for class 'orthoMTL'
predict(object, newdata, type = c("link", "response", "class"), ...)

Arguments

object

A fitted model object of class "orthoMTL".

newdata

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

type

Character; scale of the returned predictions. One of:

"link"

(default) the raw linear predictor X B (after the survival monotonicity projection, if applicable). Preserves the historical behaviour.

"response"

for logistic fits, the sigmoid 1 / (1 + e^{-XB}) giving P(Y = +1); for non-logistic fits identical to "link".

"class"

for logistic fits, the predicted class label in \{-1, +1\} (sign(XB), with 0 mapped to +1). Errors for non-logistic fits.

...

Additional arguments (currently ignored).

Details

If the fitted object contains feature_names (i.e., the training matrix X had column names), newdata columns are aligned to match. Missing features cause an error. Extra features trigger a warning and are dropped.

In survival mode (object$hyperparameters$survival == TRUE), each row of the raw prediction matrix is projected via nnmaxheap_C() to enforce non-negative, non-increasing values across tasks (time thresholds).

Value

A numeric matrix of predictions with dimensions n_new x n_tasks. Column names correspond to task names if available.

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. ECML-PKDD 2014. https://hal.science/hal-00985654

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)

orthoMTL documentation built on Aug. 23, 2026, 5:10 p.m.