| cv_orthoMTL | R Documentation |
Performs a parallelised grid search over hyperparameters for
orthoMTL, evaluating each configuration via
cross-validated concordance index. Returns the best configuration
without retraining a final model (that is the caller's responsibility).
cv_orthoMTL(
X.train,
Y.train,
W.train = NULL,
K = NULL,
lambdas = c(0.001, 0.01),
alphas = 0,
stepsizes = c(0.1, 0.5),
diag_vals = c(0.5, 1),
survival = TRUE,
logistic = FALSE,
metric = NULL,
disjoint = FALSE,
schedule = c("sqrt", "log", "const", "linear"),
folds = NULL,
n_cores = 2,
seed = NULL,
verbose = TRUE
)
X.train |
A numeric matrix of training features with dimensions
|
Y.train |
A numeric matrix of training labels with dimensions
|
W.train |
A numeric indicator matrix of dimensions
|
K |
A square constraint matrix of dimensions
|
lambdas |
A numeric vector of regularisation parameters to search. |
alphas |
A numeric vector of elastic-net mixing parameters in
|
stepsizes |
A numeric vector of gradient descent step sizes to search. |
diag_vals |
A numeric vector of diagonal values for the
constraint matrix |
survival |
Logical. Use censored survival loss? Default:
|
logistic |
Logical. Fit logistic (classification) models?
Passed through to |
metric |
Character; the scoring metric maximised/minimised over
the grid, or |
disjoint |
Logical. Enforce disjoint supports? Default:
|
schedule |
Character; the gradient-step decay schedule passed to
|
folds |
An integer vector of length |
n_cores |
Integer. Number of cores for parallel execution.
Default: |
seed |
Optional integer random seed for reproducibility. Default:
|
verbose |
Logical. Print progress information? Default:
|
The grid is constructed as the full Cartesian product of
lambdas, alphas, stepsizes, and
diag_vals. Each configuration is evaluated independently
in parallel across cores. Within each configuration, folds are
evaluated sequentially and the per-fold C-indices are averaged.
The best configuration is selected by joint maximisation of the mean CV C-index over the entire flattened grid (not greedy sequential search).
This function does not retrain a final model. Use the
returned hyperparameters to train via orthoMTL.
An object of class "cv_orthoMTL" containing:
A list with the best hyperparameters: lambda,
alpha, stepsize, diag_val, and the
corresponding cv_score.
A data.frame of all configurations with
their mean CV C-index, sorted descending by cv_score.
The fold assignment vector used.
Total number of configurations tested.
Number of unique folds.
The matched function call.
orthoMTL, cindex_mtl
set.seed(42)
n <- 50; p <- 5; n_tasks <- 3
X <- matrix(rnorm(n * p), n, p)
colnames(X) <- paste0("V", seq_len(p))
SurvTime <- rexp(n, rate = 0.1)
Event <- rbinom(n, 1, 0.7)
thresholds <- c(4, 6, 10)
Y <- create_longitudinal_labels(SurvTime, Event, thresholds)
W <- create_indicator_matrix(Y)
K <- create_constraint_matrix(n_tasks)
folds <- rep(1:2, length.out = n)
cv_res <- cv_orthoMTL(
X.train = X, Y.train = Y, W.train = W, K = K,
lambdas = c(1e-3, 1e-2), alphas = 0,
stepsizes = c(0.1), diag_vals = c(0.5, 1),
survival = TRUE, disjoint = FALSE,
folds = folds, n_cores = 1, seed = 42, verbose = FALSE
)
print(cv_res)
cv_res$best
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.