jacaCV: Cross-validation function for JACA

Description Usage Arguments Value Examples

View source: R/JACA_mian_functions.R

Description

Chooses optimal tuning parameters lambda and rho for function jacaTrain using cross-validation.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
jacaCV(
  Z,
  X_list,
  nfolds = 5,
  lambda_seq = NULL,
  n_lambda = 50,
  rho_seq = seq(0.01, 1, length = 20),
  n_rho = 5,
  missing = F,
  alpha = 0.5,
  W_list = NULL,
  kmax = 500,
  eps = 1e-06,
  verbose = F,
  foldID = NULL
)

Arguments

Z

An N by K class indicator matrix; rows are samples and columns are class indicator vectors with z_k = 1 if observation belongs to class k.

X_list

A list of input data matrices; in each sublist, rows are samples and columns are features.

nfolds

Number of cross-validation folds.

lambda_seq

The set of L1 penalty parameters to be considered. Should be chosen from 0 to 1. The default value is NULL and jacaCV generates its own sequence.

n_lambda

The number of lambda_seq considered. Used only if lambda_seq = NULL.

rho_seq

The set of L2 penalty parameters to be considered. Should be chosen from 0 to 1.

n_rho

The number of rho_seq considered. Used only if rho_seq = NULL.

missing

Logical. If False, input data X_list must be complete and have no missing values. If True, input data X_list should contain missing values.

alpha

The parameter to control the weight between optimal scoring and CCA part. Default is 0.5.

W_list

A list of inital guess of matrices of discriminant vectors (can be served as a warm start).

kmax

Max iteration number.

eps

Threshold value used to determine the convergence of the optimization algorithm; the default value is 1e-06.

verbose

Logical. If False, the algorithm will stay silent. If True, it will print out fitting progress.

foldID

User-supplied fold seperation. The default is NULL, and jacaCV generates its own folds.

Value

W_min

A list of view-specific matrices of discriminant vectors. Generated using the parameters chosen by cross-validation method.

lambda_min

The value of L1 penalty parameter that resulted in the minimal mean cross-validation error.

rho_min

The value of L2 penalty parameter that resulted in the minimal mean cross-validation error.

grid_seq

The matrix of tuning parameters used.

error_mean

The mean cross-validated error of each combination of the tuning parameters.

error_se

The standard error of cross-validated error of each combination of the tuning parameters.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
set.seed(1)
# Generate class indicator matrix Z
n = 500
Z = matrix(c(rep(1, n),rep(0, 2 * n)), byrow = FALSE, nrow = n)
for(i in 1:n){
  Z[i, ] = sample(Z[i, ])
}

# Generate input data X_list
d = 2
X_list = sapply(1:d, function(i) list(matrix(rnorm(n * 20), n, 20)))
id <- 1:nrow(Z)

# Train JACA model using cross validation
result = jacaCV(Z, X_list, nfolds = 3, lambda_seq = c(0.02, 0.04), rho_seq = c(0.3, 0.6))$W_min

# Test semi supervised learning
# Set certain class labels and subsets of views as missing
Z[90:100, ] = rep(NA, 3)
X_list[[1]][1:10, ] = NA
X_list[[2]][11:20, ] = NA

# Train JACA model using cross validation
result = jacaCV(Z, X_list, nfolds = 3, lambda_seq = c(0.02, 0.04),
                rho_seq = c(0.3, 0.6), missing = TRUE)$W_min

Pennisetum/JACA documentation built on April 30, 2021, 12:30 a.m.