-
Notifications
You must be signed in to change notification settings - Fork 1
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
tests for Brulee engines #222
base: main
Are you sure you want to change the base?
Conversation
# ------------------------------------------------------------------------------ | ||
|
||
is_torch_working <- function() { | ||
res <- try(torch::torch_tensor(1), silent = 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 is causing a warning in R CMD check as an undeclared dependency, can we not just add torch
to Suggests?
library(modeldata) | ||
library(rsample) | ||
|
||
set.seed(392) | ||
binary_tr <- sim_logistic(200, ~ .1 + 2 * A - 3 * B + 1 * A *B, corr = .7) | ||
binary_rs <- vfold_cv(binary_tr) | ||
binary_te <- sim_logistic(2, ~ .1 + 2 * A - 3 * B + 1 * A *B, corr = .7) | ||
|
||
### | ||
|
||
set.seed(392) | ||
three_class_tr <- | ||
sim_multinomial( | ||
500, | ||
~ -0.5 + 0.6 * abs(A), | ||
~ ifelse(A > 0 & B > 0, 1.0 + 0.2 * A / B, - 2), | ||
~ -0.6 * A + 0.50 * B - A * B) | ||
three_class_rs <- vfold_cv(three_class_tr) | ||
three_class_te <- | ||
sim_multinomial( | ||
2, | ||
~ -0.5 + 0.6 * abs(A), | ||
~ ifelse(A > 0 & B > 0, 1.0 + 0.2 * A / B, - 2), | ||
~ -0.6 * A + 0.50 * B - A * B) | ||
|
||
### | ||
|
||
num_tr <- sim_regression(200) | ||
num_rs <- vfold_cv(num_tr) | ||
num_te <- sim_regression(2) |
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 runs really fast, can we move all of this into functions?
@@ -0,0 +1,43 @@ | |||
test_that("linear regression via brulee", { | |||
skip_if_not_installed("torch") | |||
skip_if_not(any(get_from_env("linear_reg")$engine == "brulee")) |
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.
Can these require a specific version of parsnip instead?
expect_true(nrow(ols_pred) == 2) | ||
expect_named(ols_pred, ".pred") | ||
|
||
# ------------------------------------------------------------------------------ |
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.
Can you split these into two separate tests with more specific test descriptions, please? Applies to all tests with the # ----
separation header.
See tidymodels/parsnip#1187