forked from mehmetgonen/kbmtl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_classification.R
49 lines (35 loc) · 1.6 KB
/
demo_classification.R
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
source("kbmtl_semisupervised_classification_variational_train.R")
source("kbmtl_semisupervised_classification_variational_test.R")
#initalize the parameters of the algorithm
parameters <- list()
#set the hyperparameters of gamma prior used for projection matrix
parameters$alpha_lambda <- 1
parameters$beta_lambda <- 1
### IMPORTANT ###
#For gamma priors, you can experiment with three different (alpha, beta) values
#(1, 1) => default priors
#(1e-10, 1e+10) => good for obtaining sparsity
#(1e-10, 1e-10) => good for small sample size problems
#set the number of iterations
parameters$iteration <- 200
#set the margin parameter
parameters$margin <- 1
#set the subspace dimensionality
parameters$R <- 20
#set the seed for random number generator used to initalize random variables
parameters$seed <- 1606
#set the standard deviation of hidden representations
parameters$sigma_h <- 0.1
#set the standard deviation of weight parameters
parameters$sigma_w <- 1.0
#initialize the kernel and class labels for training
Ktrain <- ?? #should be an Ntra x Ntra matrix containing similarity values between training samples
Ytrain <- ?? #should be an Ntra x T matrix containing class labels (contains only -1s, +1s, and NaNs)
#perform training
state <- kbmtl_semisupervised_classification_variational_train(Ktrain, Ytrain, parameters)
#initialize the kernel for testing
Ktest <- ?? #should be an Ntra x Ntest matrix containing similarity values between training and test samples
#perform prediction
prediction <- kbmtl_semisupervised_classification_variational_test(Ktest, state)
#display the predicted probabilities
print(prediction$P)