Skip to content

Commit 92ead35

Browse files
topeposimonpcouch
andauthored
Updates for parsnip #1162 (#220)
* testing and snapshot updates for tidymodels/parsnip#1162 * temp add remote for testing * update two other tests/snapshots * updated results * remove parsnip `Remotes` * a few more skips based on cran version failures * a few more skips based on cran version failures --------- Co-authored-by: simonpcouch <[email protected]>
1 parent 1e9b262 commit 92ead35

25 files changed

+130
-31
lines changed

tests/testthat/_snaps/glmnet-linear.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
linear_reg(penalty = 0.01) %>% set_engine("glmnet") %>% fit(mpg ~ ., data = mtcars) %>%
2626
multi_predict(mtcars, type = "class")
2727
Condition
28-
Error in `check_pred_type()`:
28+
Error in `multi_predict()`:
2929
! For class predictions, the object should be a classification model.
3030

tests/testthat/_snaps/glmnet-logistic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@
3636
funded_amnt) + int_rate + term, data = lending_club) %>% multi_predict(
3737
lending_club, type = "time")
3838
Condition
39-
Error in `check_pred_type()`:
39+
Error in `multi_predict()`:
4040
! For event time predictions, the object should be a censored regression.
4141

tests/testthat/_snaps/glmnet-multinom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
multinom_reg(penalty = 0.01) %>% set_engine("glmnet") %>% fit(class ~ ., data = hpc_data) %>%
3434
multi_predict(hpc_data, type = "numeric")
3535
Condition
36-
Error in `check_pred_type()`:
36+
Error in `multi_predict()`:
3737
! For numeric predictions, the object should be a regression model.
3838

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# boost_tree - xgboost case weights
2+
3+
Code
4+
print(wt_fit$fit$call)
5+
Output
6+
xgboost::xgb.train(params = list(eta = 0.3, max_depth = 6, gamma = 0,
7+
colsample_bytree = 1, colsample_bynode = 1, min_child_weight = 1,
8+
subsample = 1), data = x$data, nrounds = 15, watchlist = x$watchlist,
9+
verbose = 0, nthread = 1, objective = "binary:logistic")
10+
11+
# decision_tree - rpart case weights
12+
13+
Code
14+
print(wt_fit$fit$call)
15+
Output
16+
rpart::rpart(formula = Class ~ ., data = data, weights = weights)
17+
18+
# logistic_reg - stan case weights
19+
20+
Code
21+
print(wt_fit$fit$call)
22+
Output
23+
rstanarm::stan_glm(formula = Class ~ ., family = stats::binomial,
24+
data = data, weights = weights, seed = ~1, refresh = 0)
25+
26+
# mars - earth case weights
27+
28+
Code
29+
print(wt_fit$fit$call)
30+
Output
31+
earth(formula = Class ~ ., data = data, weights = weights, keepxy = TRUE,
32+
glm = ~list(family = stats::binomial))
33+
34+
# mlp - nnet case weights
35+
36+
Case weights are not enabled by the underlying model implementation.
37+
38+
# rand_forest - ranger case weights
39+
40+
Code
41+
print(wt_fit$fit$call)
42+
Output
43+
ranger::ranger(x = maybe_data_frame(x), y = y, num.threads = 1,
44+
verbose = FALSE, seed = sample.int(10^5, 1), probability = TRUE,
45+
case.weights = weights)
46+

tests/testthat/_snaps/parsnip-survival-censoring-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
predict(alt_obj, time = 100)
2222
Condition
2323
Error in `predict()`:
24-
! Don't know how to predict with a censoring model of type: reverse_km
24+
! Don't know how to predict with a censoring model of type reverse_km.
2525

tests/testthat/_snaps/parsnip-survival-censoring-weights.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
.censoring_weights_graf("nothing useful")
55
Condition
66
Error in `.censoring_weights_graf()`:
7-
! There is no `.censoring_weights_graf()` method for objects with class(es): 'character'
7+
! There is no `.censoring_weights_graf()` method for objects with class <character>.
88

99
---
1010

1111
Code
1212
.censoring_weights_graf(cox_model, lung)
1313
Condition
1414
Error:
15-
! There should be a single column of class `Surv`
15+
! There should be a single column of class <Surv>.
1616

1717
---
1818

@@ -22,23 +22,23 @@
2222
.censoring_weights_graf(cox_model, lung_left)
2323
Condition
2424
Error in `.censoring_weights_graf()`:
25-
! For this usage, the allowed censoring type is: 'right'
25+
! For this usage, the allowed censoring type is "right".
2626

2727
---
2828

2929
Code
3030
.censoring_weights_graf(cox_model, lung2)
3131
Condition
3232
Error:
33-
! The input should have a list column called `.pred`.
33+
! The input should have a list column called ".pred".
3434

3535
---
3636

3737
Code
3838
.censoring_weights_graf(cox_model, preds, cens_predictors = "shouldn't be using this anyway!")
3939
Condition
4040
Warning:
41-
The 'cens_predictors' argument to the survival weighting function is not currently used.
41+
`cens_predictors` is not currently used.
4242
Output
4343
# A tibble: 3 x 2
4444
.pred surv
@@ -60,6 +60,6 @@
6060
Code
6161
.censoring_weights_graf(wrong_model, mtcars)
6262
Condition
63-
Error in `.check_censor_model()`:
64-
! The model needs to be for mode 'censored regression', not for mode 'regression'.
63+
Error in `.censoring_weights_graf()`:
64+
! The model needs to be for mode "censored regression", not for mode 'regression'.
6565

tests/testthat/_snaps/parsnip-survival-standalone.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
parsnip:::.is_surv(1)
55
Condition
66
Error:
7-
! The object does not have class `Surv`.
7+
! The object does not have class <Surv>.
88

99
# .check_cens_type()
1010

1111
Code
1212
parsnip:::.check_cens_type(left_c, type = "right", fail = TRUE)
1313
Condition
1414
Error:
15-
! For this usage, the allowed censoring type is: 'right'
15+
! For this usage, the allowed censoring type is "right".
1616

1717
---
1818

1919
Code
2020
parsnip:::.check_cens_type(left_c, type = c("right", "interval"), fail = TRUE)
2121
Condition
2222
Error:
23-
! For this usage, the allowed censoring types are: 'right' and 'interval'
23+
! For this usage, the allowed censoring types are "right" or "interval".
2424

tests/testthat/_snaps/randomForest.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
f_fit <- spec %>% fit(body_mass_g ~ ., data = penguins)
55
Condition
66
Warning:
7-
1000 columns were requested but there were 6 predictors in the data. 6 will be used.
7+
! 1000 columns were requested but there were 6 predictors in the data.
8+
i 6 predictors will be used.
89
Warning:
9-
1000 samples were requested but there were 333 rows in the data. 333 will be used.
10+
! 1000 samples were requested but there were 333 rows in the data.
11+
i 333 samples will be used.
1012

1113
---
1214

1315
Code
1416
xy_fit <- spec %>% fit_xy(x = penguins[, -6], y = penguins$body_mass_g)
1517
Condition
1618
Warning:
17-
1000 columns were requested but there were 6 predictors in the data. 6 will be used.
19+
! 1000 columns were requested but there were 6 predictors in the data.
20+
i 6 predictors will be used.
1821
Warning:
19-
1000 samples were requested but there were 333 rows in the data. 333 will be used.
22+
! 1000 samples were requested but there were 333 rows in the data.
23+
i 333 samples will be used.
2024

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# recipe steps with non-varying args error if specified as varying()
2+
3+
Code
4+
varying_args(rec_bad_varying)
5+
Condition
6+
Error in `map()`:
7+
i In index: 1.
8+
Caused by error in `map2()`:
9+
i In index: 5.
10+
i With name: skip.
11+
Caused by error in `.f()`:
12+
! The argument skip for a recipe step of type "step_type" is not allowed to vary.
13+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Correct values
2+
3+
Code
4+
print(rec)
5+
Message
6+
7+
-- Recipe ----------------------------------------------------------------------
8+
9+
-- Inputs
10+
Number of variables by role
11+
outcome: 1
12+
predictor: 4
13+
14+
-- Operations
15+
* Non-negative matrix factorization for: all_predictors()
16+
17+
# No NNF
18+
19+
Code
20+
print(rec)
21+
Message
22+
23+
-- Recipe ----------------------------------------------------------------------
24+
25+
-- Inputs
26+
Number of variables by role
27+
outcome: 1
28+
predictor: 4
29+
30+
-- Training information
31+
Training data contained 150 data points and no incomplete rows.
32+
33+
-- Operations
34+
* No non-negative matrix factorization was extracted from: Sepal.Length,
35+
Sepal.Width, Petal.Length, Petal.Width | Trained
36+

0 commit comments

Comments
 (0)