Description Usage Arguments Value Examples
View source: R/JACA_mian_functions.R
Chooses optimal tuning parameters lambda and rho for function jacaTrain
using cross-validation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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 |
n_lambda |
The number of |
rho_seq |
The set of L2 penalty parameters to be considered. Should be chosen from 0 to 1. |
n_rho |
The number of |
missing |
Logical. If False, input data |
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 |
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. |
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.