-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delint and debug #273
Delint and debug #273
Conversation
Warning Rate limit exceeded@zachmayer has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 48 minutes and 17 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe recent changes primarily focus on improving code readability, maintainability, and style consistency across the project. Significant updates include reformatting code to standardize spacing and alignment, especially around assignment operators, enhancing comments for clarity, and updating function parameter formats. Moreover, new configuration files for linters and build tools have been introduced, and the Makefile has been updated to streamline the build process by adding new targets and removing redundancy. Changes
Sequence Diagram(s)Since the changes primarily involve code reformatting, linting configuration, and Makefile updates, no new features or control flow modifications require visualization through sequence diagrams. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (34)
- .Rbuildignore (1 hunks)
- .coderabbit.yaml (1 hunks)
- .lintr (1 hunks)
- Makefile (2 hunks)
- R/S3GenericExtenstions.R (2 hunks)
- R/caretEnsemble-package.R (1 hunks)
- R/caretEnsemble.R (16 hunks)
- R/caretList.R (13 hunks)
- R/caretStack.R (8 hunks)
- R/helper_functions.R (14 hunks)
- inst/data-raw/build_test_data.R (2 hunks)
- man/autoplot.Rd (1 hunks)
- man/c.caretList.Rd (1 hunks)
- man/c.train.Rd (1 hunks)
- man/caretEnsemble.Rd (1 hunks)
- man/caretList.Rd (1 hunks)
- man/caretModelSpec.Rd (1 hunks)
- man/caretStack.Rd (1 hunks)
- man/dotplot.caretStack.Rd (1 hunks)
- man/plot.caretEnsemble.Rd (1 hunks)
- man/plot.caretStack.Rd (1 hunks)
- man/predict.caretStack.Rd (1 hunks)
- man/print.caretStack.Rd (1 hunks)
- man/summary.caretEnsemble.Rd (1 hunks)
- man/summary.caretStack.Rd (1 hunks)
- tests/testthat/test-S3-generic-extensions.R (3 hunks)
- tests/testthat/test-caretList.R (15 hunks)
- tests/testthat/test-caretStack.R (4 hunks)
- tests/testthat/test-classSelection.R (6 hunks)
- tests/testthat/test-ensemble.R (10 hunks)
- tests/testthat/test-ensembleMethods.R (11 hunks)
- tests/testthat/test-helper_functions.R (7 hunks)
- tests/testthat/test-parallel.R (2 hunks)
- vignettes/caretEnsemble-intro.Rmd (7 hunks)
Files not reviewed due to errors (1)
- tests/testthat/test-classSelection.R (no review received)
Files skipped from review due to trivial changes (28)
- .Rbuildignore
- .coderabbit.yaml
- R/caretEnsemble-package.R
- R/caretEnsemble.R
- R/caretList.R
- R/caretStack.R
- R/helper_functions.R
- inst/data-raw/build_test_data.R
- man/autoplot.Rd
- man/c.caretList.Rd
- man/c.train.Rd
- man/caretEnsemble.Rd
- man/caretList.Rd
- man/caretModelSpec.Rd
- man/caretStack.Rd
- man/plot.caretEnsemble.Rd
- man/plot.caretStack.Rd
- man/predict.caretStack.Rd
- man/print.caretStack.Rd
- man/summary.caretEnsemble.Rd
- man/summary.caretStack.Rd
- tests/testthat/test-S3-generic-extensions.R
- tests/testthat/test-caretStack.R
- tests/testthat/test-ensemble.R
- tests/testthat/test-ensembleMethods.R
- tests/testthat/test-helper_functions.R
- tests/testthat/test-parallel.R
- vignettes/caretEnsemble-intro.Rmd
Additional comments not posted (11)
.lintr (2)
4-4
: Cyclomatic complexity linter added.This addition helps maintain code quality by enforcing a complexity limit of 16, which is a common threshold for maintaining manageable function complexity.
2-2
: Consider updating the line length as planned.The TODO comment suggests a planned reduction in line length from 305 to 120, which aligns with common coding standards for better readability.
man/dotplot.caretStack.Rd (1)
24-29
: Updated example code in documentation.The example code has been updated to reflect the correct usage of the
caretList
andcaretStack
functions with proper formatting and method assignments. Ensure that these examples are tested to verify their correctness.Also applies to: 33-33
Makefile (1)
3-3
: Updated Makefile with new targets and order.The Makefile has been restructured to include new targets such as
update-test-fixtures
andfix-style
, and to change the default build sequence. This should enhance the development process by ensuring that style fixes and tests are prioritized.Also applies to: 6-6, 18-21, 30-34, 36-37
R/S3GenericExtenstions.R (1)
14-21
: Enhanced documentation and error handling in S3 methods.The documentation examples have been updated for clarity and accuracy. Additionally, the functions now include better error handling to ensure that only
caretList
ortrain
objects are processed, which enhances robustness.Also applies to: 24-31, 33-33, 38-39, 86-87
tests/testthat/test-caretList.R (6)
99-104
: Testing different configurations of trainControl and methodsThe modifications in the
trainControl
function parameters and method list are aimed at testing different configurations. Confirm that these changes are consistent with the intended testing scenarios and that all configurations are adequately covered.
77-82
: Enhanced testing configurations for edge casesThe introduction of specific testing configurations for
caretModelSpec
improves coverage of potential edge cases, ensuring robustness. Verify that these configurations are tested across different scenarios and align with the overall testing strategy.Verification successful
Enhanced testing configurations for edge cases
The introduction of specific testing configurations for
caretModelSpec
improves coverage of potential edge cases, ensuring robustness. The functioncaretModelSpec
is tested across various scenarios in multiple test files, demonstrating a comprehensive testing strategy.
tests/testthat/test-ensemble.R
tests/testthat/test-S3-generic-extensions.R
tests/testthat/test-caretList.R
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the testing configurations across different scenarios. # Test: Search for similar configurations in other test files. rg --type R $'caretModelSpec'Length of output: 54
Script:
#!/bin/bash # Description: Verify the testing configurations across different scenarios. # Test: Search for similar configurations in other test files. rg --glob '*.R' 'caretModelSpec'Length of output: 3442
190-208
: Comprehensive testing of different CV methodsThe adjustments in the
trainControl
function parameters for different CV methods enhance the test's comprehensiveness. Ensure that all CV methods are correctly handled and that the test scenarios reflect realistic use cases.Verification successful
Comprehensive testing of different CV methods
The adjustments in the
trainControl
function parameters for different CV methods enhance the test's comprehensiveness. The different CV methods are correctly handled, and the test scenarios reflect realistic use cases.
- Verified instances of
trainControl
usage in various test scenarios across the project.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the handling of different CV methods in the test environment. # Test: Search for different CV methods across the project. rg --type R $'trainControl'Length of output: 52
Script:
#!/bin/bash # Description: Verify the handling of different CV methods in the test environment. # Find all R files and search for the usage of trainControl fd -e R -x rg 'trainControl' {}Length of output: 5223
27-30
: Improved clarity in method specificationThe explicit setting of method parameters in
caretModelSpec
calls enhances clarity and ensures the correct methods are being tested. Verify that these method specifications align with intended test coverage.Verification successful
Improved clarity in method specification
The explicit setting of method parameters in
caretModelSpec
calls enhances clarity and ensures the correct methods are being tested. The method specifications align well with the intended test coverage.
tests/testthat/test-caretList.R
: Lines 27-30Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the alignment of method specifications with intended test coverage. # Test: Search for the method specifications across the project. rg --type R $'caretModelSpec'Length of output: 54
Script:
#!/bin/bash # Description: Verify the alignment of method specifications with intended test coverage. # Locate all R files and search for `caretModelSpec` calls within those files. fd -e R -x rg 'caretModelSpec' {}Length of output: 2336
451-463
: Testing custom tuneList with specific parametersThe setup of a custom tuneList with specific tuning parameters is crucial for testing the flexibility and robustness of the model training process. Verify that these parameters are correctly handled and that the test scenarios are comprehensive.
Verification successful
Testing custom tuneList with specific parameters
The setup of a custom tuneList with specific tuning parameters is crucial for testing the flexibility and robustness of the model training process. The verification confirms that these parameters are correctly handled and that the test scenarios are comprehensive.
tests/testthat/test-caretList.R
: Multiple occurrences oftuneList
usage.tests/testthat/test-ensemble.R
:tuneList
used in different test scenarios.- Documentation files also reference
tuneList
, indicating detailed usage instructions.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the handling of custom tuneList parameters in the test environment. # Test: Search for the usage of custom tuneList parameters across the project. rg --type R $'tuneList'Length of output: 48
Script:
#!/bin/bash # Description: Verify the handling of custom tuneList parameters in the test environment. # Test: Search for the usage of custom tuneList parameters across the project. rg 'tuneList'Length of output: 5265
15-16
: Enhanced test setup for robustnessThe changes in the parameters for
twoClassSim
seem intended to enhance the test's robustness by adjusting the correlation variables and values. Confirm that these values align with the expected testing scenarios.Also applies to: 19-20
Verification successful
Enhanced test setup for robustness
The changes in the parameters for
twoClassSim
seem intended to enhance the test's robustness by adjusting the correlation variables and values. The updated parameters align with the expected testing scenarios.
tests/testthat/test-caretList.R
: lines 15-16 and 19-20Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage and impact of the new parameters in the test environment. # Test: Search for the function usage in other test files. rg --type R $'twoClassSim'Length of output: 51
Script:
#!/bin/bash # Description: Verify the usage and impact of the new parameters in the test environment. # Test: Search for the function usage in other test files. rg 'twoClassSim' --glob '*.R'Length of output: 136
Script:
#!/bin/bash # Description: Extract lines where `twoClassSim` is called in the `tests/testthat/test-caretList.R` file to verify parameter changes. # Extract relevant lines from the test file. rg 'twoClassSim' --glob 'tests/testthat/test-caretList.R' -A 3 -B 3Length of output: 688
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (14)
- .lintr (1 hunks)
- R/caretList.R (13 hunks)
- R/helper_functions.R (14 hunks)
- inst/data-raw/build_test_data.R (2 hunks)
- tests/testthat.R (1 hunks)
- tests/testthat/test-S3-generic-extensions.R (4 hunks)
- tests/testthat/test-a-skip.R (1 hunks)
- tests/testthat/test-caretList.R (15 hunks)
- tests/testthat/test-caretStack.R (3 hunks)
- tests/testthat/test-ensemble.R (10 hunks)
- tests/testthat/test-ensembleMethods.R (11 hunks)
- tests/testthat/test-helper_functions.R (7 hunks)
- tests/testthat/test-parallel.R (2 hunks)
- vignettes/caretEnsemble-intro.Rmd (5 hunks)
Files skipped from review due to trivial changes (1)
- tests/testthat.R
Files skipped from review as they are similar to previous changes (12)
- .lintr
- R/caretList.R
- R/helper_functions.R
- inst/data-raw/build_test_data.R
- tests/testthat/test-S3-generic-extensions.R
- tests/testthat/test-caretList.R
- tests/testthat/test-caretStack.R
- tests/testthat/test-ensemble.R
- tests/testthat/test-ensembleMethods.R
- tests/testthat/test-helper_functions.R
- tests/testthat/test-parallel.R
- vignettes/caretEnsemble-intro.Rmd
Additional comments not posted (2)
tests/testthat/test-a-skip.R (2)
4-4
: Ensure intentional failure is correct for testing.The test intentionally fails by asserting
expect_equal(1, 0)
. If this is meant to test theskip
functionality, it's correctly placed after theskip
call to ensure it does not execute.
8-8
: Proper use of conditional skipping for CRAN environments.The use of
skip_on_cran()
is appropriate for tests that should not run in the CRAN environment but are valid in other contexts. The test itself is a simple check that effectively serves as a placeholder to ensure test mechanics are correct when not skipped.
stop("Not yet implemented for multiclass problems") | ||
# Warn that we have not yet implemented multiclass models | ||
# add a check that if this is null you did not set savePredictions in the trainControl | ||
# TODO: add support for non-prob models (e.g. rFerns) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small bug fix here: this is more than just linting. Resolve an error if the first model in the list is different from the others.
Un-commented the test here, which had a comment about the bug: https://github.com/zachmayer/caretEnsemble/pull/273/files#diff-ba47473171653c28531fd5772a47eea8a0311c9fa86cb171a069253888444b95L52
#NOT YET SUPPORTED | ||
# y <- factor(ifelse(iris[,5]=="versicolor", "yes", "no")) | ||
# mod <- train(iris[,1:2], y, method="glm", trControl=trainControl(method="cv", number=3, savePredictions=TRUE)) | ||
# r <- residuals(mod) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
caret.residuals doesn't support classification models (lets update it sometime so it does, and while we're add it save class probs by default)
@@ -30,22 +29,21 @@ test_that("We can get variable importance in ensembles", { | |||
expect_is(varImp(ens.reg, scale = TRUE, weight = TRUE), "data.frame") | |||
}) | |||
|
|||
test_that("We get warnings when scale is set to FALSE and weight is TRUE", { | |||
skip_on_cran() | |||
test_that("varImp works for caretEnsembles", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made this test easier to follow with a loop (instead of the unrolled loop), and checks for the rows/cols at each loop iteration.
#expect_true(identical(round(mr2[mr2$method == "rpart", "resid"], 5), round(mr2.tmp2, 5))) | ||
|
||
#I think the factors are backward somewhere in here | ||
#Also, caret doesn't yet support residuals for classification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted as caret doesn't support residuals for classificaiton.
newDat <- ens.class$models[[3]]$trainingData | ||
newDat[2, 2] <- NA | ||
newDat[3, 3] <- NA | ||
newDat[4, 4] <- NA | ||
newDat <- newDat[1:10, ] | ||
# expect_error(predict(ens.class, newdata = newDat, return_weights=TRUE, se=FALSE)) # BUG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed this bug by re-adding the random forest model to the ens.class (note that the rest are ens.reg). The "bug" was because the random forest model is the only one that can't handle these NAs and thus returns an error.
So in the old test, no RF meant no error. Now that every test case has an RF, they all fail.
) | ||
models2 <- c(new_model, models) | ||
models3 <- c(models, new_model) | ||
check_caretList_model_types(models) | ||
expect_error(check_caretList_model_types(models2)) | ||
#expect_error(check_caretList_model_types(models3)) #THIS IS A BUG THAT NEEDS FIXING!!!!!!!!!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix above that checks all models, not just the first in the list, fixes this bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antongomez PR to delint the codebase. I'll then rebase my initial multiclass branch off this