DLDA

Accomplished using R dlda in sparsediscrim packages.


In [1]:
suppressMessages(library(sparsediscrim))
load("../transformed data/golub3571.rda")
load("../transformed data/paper9.rda")
# Settings as specified in the paper
p = 40 # number of genes for FLDA
B = 50 # Aggregation predictors
N = 200 # repeat classification N times
d = c(0.05, 0.1,0.25, 0.5, 0.75, 1) # CPD parameter
set.seed(2017)

In [2]:
cbine_data = data.frame(response = factor(total3571_response), scale_golub_merge)
dlda_error = numeric(N)
for(i in 1:200){
    dlda_index = mysplit(nrow(cbine_data))
    dlda_train = cbine_data[-dlda_index,]
    dlda_test = cbine_data[dlda_index,]
    
    # gene selection
    temp_bw = order(BW(dlda_train[, -1], dlda_train$response), decreasing = T)[1:p]
    dlda_train_t = data.frame(response = dlda_train$response, dlda_train[,temp_bw+1])
    dlda_test_t= data.frame(response = dlda_test$response, dlda_test[,temp_bw+1])
    
    dlda_md = dlda(response~., data = dlda_train_t)
    dlda_pred = predict(dlda_md, dlda_test_t[, -1])$class
    dlda_error[i] = sum(dlda_pred != dlda_test_t$response)
}
resultDLDA = c(Median = median(dlda_error), Upper_quartile = quantile(dlda_error, 0.75))

In [3]:
resultDLDA


Median
1
Upper_quartile.75%
2