R/loadIterationResults.R

Defines functions getIterationData

getIterationData = function(path) {
  results = NULL
  # resultDfAggFilter = NULL

  # define relevant cols of csv
  cols = c("fw.abs", "mmce.test.mean", "method", "classifier", "dataset", "iter", "exec.time", "dob")

  # get datasets
  datasets = list.dirs(path = path, full.names = F, recursive = F)

  for(dataset in datasets) {
    dataset_path = paste(path, dataset, sep = "/")

    # get classifier
    classifiers = list.dirs(path = dataset_path, full.names = F, recursive = F)

    for (classifier in classifiers) {
      # get iterations
      iterations = list.dirs(path = paste(dataset_path, classifier, sep = "/"), full.names = F, recursive = F)
      # print(iterations)

      for (iteration in iterations) {
        # build current path
        iteration_path = paste(dataset_path, classifier, iteration, sep = "/")

        aggr_file_path = list.files(iteration_path)
        hyper_file = aggr_file_path[startsWith(aggr_file_path, "Hyper")]

        # check if done.txt exists
        if (length(hyper_file) > 0) {
          # load result of iteration
          result_temp = readr::read_delim(
            paste(iteration_path, hyper_file, sep = "/"),
            ";"
          )

          # set classifier
          result_temp$classifier = classifier
          result_temp$dataset = dataset

          # append to results filter
          if("fw.abs" %in% colnames(result_temp)) {
            if (is.null(results)) {
              # browser()
              results = result_temp[,cols]
            }
            else {
              # browser()
              results = rbind(results, result_temp[,cols])
            }
          }
        }
      }
    }
  }

  return(results)
}
creil94/FeatureSelectionDashboard documentation built on Nov. 4, 2019, 9:17 a.m.