https://github.com/rgmantovani/TuningAnalysis
Raw File
Tip revision: 399051d40991d27f92d65c09bb2923ce26a6e00b authored by Rafael G. Mantovani on 06 February 2024, 23:16:05 UTC
Update README.md with raw results' drive link
Tip revision: 399051d
01_mainAnalysis.R
#--------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------

mainAnalysis = function(parsed.obj) {

  cat("*******************************************\n")
  cat("* Automated Hyperparameter tuning Analysis\n")
  cat("*******************************************\n")

  devtools::load_all(path = ".")

  algo  = parsed.obj$algo

  #----------------------
  #----------------------

  checkmate::assertChoice(x = algo, choices = AVAILABLE.ALGOS, .var.name = "algo")

  n.files = list.files(path = paste0("data/hptuning_full_space/", algo, "/results/"), recursive = TRUE)
  if(length(n.files) == 0) {
    stop(paste0("There is no result for algo: ", algo, "\n"))
  } else {
    cat(" * results found ... beginning the analysis ...\n")
  }

  cat("*******************************************\n")
  cat(paste0("* Doing Analysis for algo: ", algo,"\n"))
  cat("*******************************************\n")

  #----------------------
  #----------------------

  cat("* Checking required data for analyzes: \n")

  # ----------------------------
  # ----------------------------

  # Raw results in: data/hptuning_full_space/{algo} /results
  # For an {algo}, we must extract from raw data:
  
  # ----------------------------
  # * 01: extract all performances 
  # ----------------------------
  
  if(!checkSubdir(algo = algo, space = "full", subdir="extracted_results")) {
    stop("Plase, run the script: \'01_extractRepResults.R\'\n")
  } else {
    cat("  - all performances overall repetitions already extracted: \tok\n")
  }
  
  # ----------------------------
  # ----------------------------
  
  # * 02: extract all optimization paths
  if(!checkSubdir(algo = algo, space = "full", subdir="opt_paths")) {
    stop("Plase, run the script: \'02_extractOptPaths.R\'\n")
  } else {
    cat("  - all optimization paths were already extracted: \t\tok\n")
  }

  # ----------------------------
  # ----------------------------

  # * 03: extract models' statistics
  if(!checkSubdir(algo = algo, space = "full", subdir="models_stats")) {
    stop("Plase, run the script: \'03_extractModelsStats.R\'\n")
  } else {
    cat("  - all models's statistics were already extracted: \t\tok\n")
  }

  # ----------------------------
  # ----------------------------

  # * 04: extract fanova files (data/algorithm/fullspace/fanova_input)
  # fAnova is external
  if(!checkSubdir(algo = algo, space = "full", subdir = "fanova_output")) {
    stop("You did not generate fAnova info from HPs. Plase, generate them first.\n")
  } else {
    cat("  - all fanova results were already extracted: \t\t\tok\n")
  }

  #----------------------
  #----------------------

  # Calling Analysis
  runAnalysis(algo = algo)

  cat("* Done\n")
  cat("*******************************************\n")
}

#--------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------

options(echo = TRUE)
args = commandArgs(trailingOnly = TRUE)

option_list = list(
  optparse::make_option(c("--algo"),  type="character", action="store",
    help = "ML algorithm")
)

parsed.obj = optparse::parse_args(optparse::OptionParser(option_list=option_list), args = args)
# print(parsed.obj)

# Calling execution
mainAnalysis(parsed.obj = parsed.obj)

#--------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------
back to top