You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tests/testthat/test-pipeline.R : end-to-end runMLPipeline() with cross-validation instead of a train/validation/test split: output structure, signal recovery, return_fit / return_pred / return_tune_res, shuffle_labels baseline, multi-class rejection for non-LR models, removeTopFeats.
Helpers in helper-fixtures.R and helper-ml-fixture.R build small tibbles for fast pipeline tests.
Known issue -
This note is just a heads-up that the tests uncovered a pre-existing bug in runMLPipeline() that's worth fixing in a follow-up PR:
When you call runMLPipeline() with a train/validation/test split (e.g. split = c(0.6, 0.2)), it crashes. The pipeline turns off cross-validation in this mode, but the tuning step still tries to run cross-validation and errors out. Until that's fixed, the pipeline tests only cover the cross-validation mode (split = c(1, 0)). The tests are sufficient as-is so no action should be needed from the reviewer to merge them - this is just a note for a future fix.
How to run the tests
Locally, from the package root (amRml/):
# Option A — devtools (recommended during development)devtools::test()
# Option B — R CMD check (full package check, including tests)devtools::check()
Orfromtheshell:cdamRmlRscript-e'devtools::test()'Expected: [ FAIL0|WARN0|SKIP0|PASS200 ].
@eboyer221 I looked into the preexisting train/validation/test split bug and added a test showing that runMLPipeline() now returns the expected structure with split = c(0.6, 0.2).
The change is line 264 of core_ml.R where initial_validation_split now uses:
rsample::validation_set(data_split)
instead of calling vfold_cv().
In run_ml_pipeline.R, there is this conditional for when 0 is passed is for the split where the nfold is set to NA.
# Set `n_fold` to `NA` if not using cross-validation.if (split[2] !=0) {
n_fold<-NA
}
The crash was because the original vfold_cv should not be taking an NA for the number of folds, in this mode the existing validation partition should be used rather than creating new folds. I ran with the validation split and a cv split and I see similar, overlapping top importance score features.
If this solution makes sense to you, ill approve for merging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
testthattest suite covering helpers and the full runMLPipeline() flow.Coverage
tests/testthat/test-arg-checks.R: every internal.checkArg*validator inR/arg_check_ml.Rtests/testthat/test-prep-ml.R:.getTargetVarName,getNumFeat,shuffleLabels,calculateMinSamples,loadMLInputTibble.tests/testthat/test-fisher.R:encodePhenotype,runFisherTests,applyBenjaminiHochberg,computeFeatureFreq.tests/testthat/test-core-ml.R:splitMLInputTibble,buildRecipe,buildLRModel,buildWflow,buildTuningGrid,predictML/getConfusionMatrix/calculateEvalMets/extractTopFeats.tests/testthat/test-pipeline.R: end-to-endrunMLPipeline()with cross-validation instead of a train/validation/test split: output structure, signal recovery,return_fit/return_pred/return_tune_res,shuffle_labelsbaseline, multi-class rejection for non-LR models,removeTopFeats.Helpers in
helper-fixtures.Randhelper-ml-fixture.Rbuild small tibbles for fast pipeline tests.Known issue -
This note is just a heads-up that the tests uncovered a pre-existing bug in runMLPipeline() that's worth fixing in a follow-up PR:
When you call runMLPipeline() with a train/validation/test split (e.g. split = c(0.6, 0.2)), it crashes. The pipeline turns off cross-validation in this mode, but the tuning step still tries to run cross-validation and errors out. Until that's fixed, the pipeline tests only cover the cross-validation mode (split = c(1, 0)). The tests are sufficient as-is so no action should be needed from the reviewer to merge them - this is just a note for a future fix.
How to run the tests
Locally, from the package root (
amRml/):