predictJACA: Classification method for JACA model

Description Usage Arguments Value Examples

View source: R/JACA_mian_functions.R

Description

Classify observations in the test set based on the supplied matrices of canonical vectors W_list and the training datasets. This function first fits a linear discriminant analysis model based on W_list, trainx and trainz, then makes predictions by W_list, testx.

Usage

1
predictJACA(W_list, trainx, trainz, testx, posterior = F)

Arguments

W_list

A list of view-specific matrices of discriminant vectors. Should be the results of jacaTrain or jacaCV.

trainx

A list of input data matrices that are used to generate the model: in each sublist, samples are rows and columns are features.

trainz

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

testx

A list of input data matrices Predictions will be made using it.

posterior

Logical. If TRUE, the function outputs the posterior probabilities for the classes, otherwise it will outputs the class assignments results.

Value

prediction

An n by D matrix with predicted group labels for the test set if posterior = FALSE. Columns are predictions made by each dataset seperately. Otherwise it is a list of posterior probabilities for the test set.

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
set.seed(1)
# Generate class indicator matrix Z
n = 100
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)))

# Train the model
result = jacaTrain(Z, X_list, lambda = rep(0.05, 2), verbose = FALSE, alpha= 0.5, rho = 0.2)

# Make predictions by each dataset seperately
zTest = predictJACA(result, X_list, Z, X_list)

# Make predictions by the concatenated dataset
wJoint = list()
wJoint[[1]] = do.call(rbind, result)
xTrain = list()
xTrain[[1]] = do.call(cbind, X_list)
zTestConcatenated = predictJACA(wJoint, xTrain, Z, xTrain)

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