R/loadTopcvfNB.R

loadTopcvfNB <- function(k, listFeatureChoices, mismatchTuning, mismatchTesting,
                         cvFolds){

    ## Error checking parameters
    if(round(k) != k && k > 0){
        stop("k must be a positive integer.")
    }

    ## Error checking parameters
    if(round(cvFolds) != cvFolds && cvFolds > 0){
        stop("cvFolds must be a positive integer.")
    }

    ## Progress message
    message(paste0("Identifying top ",  k, " feature combinations."))

    ## Finding top k combinations
    interestingCombos <- topcvfNB(k = k,
                                  listFeatureChoices = listFeatureChoices,
                                  mismatchTuning = mismatchTuning,
                                  mismatchTesting = mismatchTesting)

    ## Progress message
    message(paste0("Selecting top ", k, " feature combinations in summary output"))

    ## Reconstruct DT_MAP from individual folds, choosing only the top 10 best
    nbOutput <- vector("list", length=cvFolds)
    for(folds in 1:cvFolds){
        load(paste("Output_CV_", folds, ".rda", sep=""))
        nbOutput[[folds]] <- DT_Full[[folds]][interestingCombos]
        rm(DT_Full)
    }

    return(nbOutput)
}
jchitpin/blistR documentation built on July 8, 2019, 6:29 p.m.