Creates a structured directory hierarchy for storing machine learning results including matrices, performance metrics, feature importance, models, and predictions.

createMLResultDir(
  path,
  stratify_by = NULL,
  LOO = FALSE,
  cross_test = FALSE,
  MDR = FALSE
)

Arguments

path

Character scalar. Base directory path where subdirectories will be created.

stratify_by

Character scalar or NULL. Stratification method: "country", "year", or NULL. Default is NULL (no stratification).

LOO

Logical. Whether to create directories for Leave-One-Out analysis. Default is FALSE. Only valid when stratify_by is not NULL.

cross_test

Logical. Whether to create directories for cross-testing. Default is FALSE.

MDR

Logical. Whether to create directories for Multi-Drug Resistance (MDR) analysis. Default is FALSE. When TRUE, all other parameters must be FALSE/NULL.

Value

A named list containing paths to:

matrix_path

Directory for input matrices

ML_performance

Directory for performance metrics

ML_top_features

Directory for top feature rankings

ML_models

Directory for saved model objects

ML_prediction

Directory for prediction results

Examples

out_dir <- file.path(tempdir(), "amRml_createdir_example")
dir.create(out_dir, showWarnings = FALSE, recursive = TRUE)
createMLResultDir(out_dir)
#> $matrix_path
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/matrix"
#> 
#> $ML_performance
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/ML_performance"
#> 
#> $ML_top_features
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/ML_top_features"
#> 
#> $ML_models
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/ML_models"
#> 
#> $ML_prediction
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/ML_pred"
#> 
createMLResultDir(out_dir, stratify_by = "year", LOO = TRUE)
#> $matrix_path
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/LOO_matrix_year"
#> 
#> $ML_performance
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/LOO_ML_year_performance"
#> 
#> $ML_top_features
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/LOO_ML_year_top_features"
#> 
#> $ML_models
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/LOO_ML_year_models"
#> 
#> $ML_prediction
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/LOO_ML_year_pred"
#> 
createMLResultDir(out_dir, MDR = TRUE)
#> $matrix_path
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/MDR_matrix"
#> 
#> $ML_performance
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/MDR_ML_performance"
#> 
#> $ML_top_features
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/MDR_ML_top_features"
#> 
#> $ML_models
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/MDR_ML_models"
#> 
#> $ML_prediction
#> [1] "/tmp/RtmpP4bRCC/amRml_createdir_example/MDR_ML_pred"
#>