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
)Character scalar. Base directory path where subdirectories will be created.
Character scalar or NULL. Stratification method: "country",
"year", or NULL. Default is NULL (no stratification).
Logical. Whether to create directories for Leave-One-Out analysis.
Default is FALSE. Only valid when stratify_by is not NULL.
Logical. Whether to create directories for cross-testing.
Default is FALSE.
Logical. Whether to create directories for Multi-Drug Resistance (MDR) analysis.
Default is FALSE. When TRUE, all other parameters must be FALSE/NULL.
A named list containing paths to:
Directory for input matrices
Directory for performance metrics
Directory for top feature rankings
Directory for saved model objects
Directory for prediction results
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"
#>