-
Notifications
You must be signed in to change notification settings - Fork 8
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
improve error messages #80
base: main
Are you sure you want to change the base?
Conversation
@@ -89,6 +89,7 @@ | |||
#' cart_pca_bag | |||
#' } | |||
#' @export | |||
#' @include validate.R |
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.
DOWN WITH aaa FILES
} | ||
|
||
# TODO extend to use mode from model object(s) |
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.
We could eventually extend baguette to censored regression models. There is a lot of code that looks at the data to get the mode or assumes that they are either regression or classification.
} | ||
|
||
if (!is.na(msg)) { | ||
# escape any brackets in the error message |
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.
A long way to get there but this should make much much nicer error messages when models fail
Code | ||
bagger(Sepal.Length ~ ., data = iris, times = 2L, base_model = "C5.0") | ||
Condition | ||
Error in `validate_outcomes_are_factors()`: |
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.
All of our snapshots are going to change once these hardhat functions can take calls
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.
Looking good!
by looking at the snapshots, i see some calls aren't passed through to hardhat::validate_outcomes_are_factors()
and
validate_outcomes_are_univariate()
. these don't yet have call
arguments so we have to wait for {hardhat} for them
there is also a call to stop()
on line 100 of R/bagger.R
that needs to be converted. Wasn't able to tag directly as it is "outside of github scope"
expect_snapshot({ | ||
set.seed(459394) | ||
bagger(a ~ ., data = bad_iris, base_model = "CART", times = 3) | ||
}, | ||
error = TRUE | ||
) |
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.
This snapshot bubbles up the issue that check_for_disaster()
doesn't pass calls around
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.
at one point in time. ideally this should say Error in
bagger():
not Error in
check_for_disaster():
} | ||
|
||
integer_B <- function(B) { | ||
if (is.numeric(B) & !is.integer(B)) { |
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.
if (is.numeric(B) & !is.integer(B)) { | |
if (is.double(B)) { |
msg <- gsub("(\\{)", "\\1\\1", msg) | ||
msg <- gsub("(\\})", "\\1\\1", msg) | ||
msg <- cli::format_error(msg) |
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.
as per r-lib/cli#735 (comment)
msg <- gsub("(\\{)", "\\1\\1", msg) | |
msg <- gsub("(\\})", "\\1\\1", msg) | |
msg <- cli::format_error(msg) | |
msg <- cli::format_error("{msg}") |
rpart, | ||
rsample, | ||
tibble, | ||
tidyr, | ||
utils, | ||
withr | ||
Suggests: | ||
AmesHousing, |
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.
i'm going to assume that this is leftover from a long time ago, and that we don't need it since we have modeldata
This needed sooo much upkeep that it was difficult to separate the different modes of error upgrades.
This PR adds type checkers, refines cli messages, routes calls to the user-facing function, and cleans up a bunch of dplyr/purrr calls that lack namespaces.