Skip to content

Commit b5284b0

Browse files
committed
snapshot updates
1 parent 1151a2c commit b5284b0

29 files changed

+2058
-6
lines changed

tests/testthat/_snaps/adds.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# adding row indicies
2+
3+
Code
4+
add_rowindex(as.matrix(mtcars))
5+
Condition
6+
Error in `add_rowindex()`:
7+
! `x` should be a data frame.
8+

tests/testthat/_snaps/boost_tree.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
# updating
2+
3+
Code
4+
update(set_engine(boost_tree(trees = 1), "C5.0", noGlobalPruning = TRUE),
5+
trees = tune(), noGlobalPruning = tune())
6+
Output
7+
Boosted Tree Model Specification (unknown mode)
8+
9+
Main Arguments:
10+
trees = tune()
11+
12+
Engine-Specific Arguments:
13+
noGlobalPruning = tune()
14+
15+
Computational engine: C5.0
16+
17+
18+
# bad input
19+
20+
Code
21+
boost_tree(mode = "bogus")
22+
Condition
23+
Error in `boost_tree()`:
24+
! "bogus" is not a known mode for model `boost_tree()`.
25+
26+
---
27+
28+
Code
29+
translate(boost_tree(mode = "classification"), engine = NULL)
30+
Message
31+
Used `engine = 'xgboost'` for translation.
32+
Output
33+
Boosted Tree Model Specification (classification)
34+
35+
Computational engine: xgboost
36+
37+
Model fit template:
38+
parsnip::xgb_train(x = missing_arg(), y = missing_arg(), weights = missing_arg(),
39+
nthread = 1, verbose = 0)
40+
141
# check_args() works
242

343
Code
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# C5.0 execution
2+
3+
Code
4+
res <- fit(lc_basic, funded_amnt ~ term, data = lending_club, engine = "C5.0",
5+
control = ctrl)
6+
Condition
7+
Error in `.convert_form_to_xy_fit()`:
8+
! The argument `engine` cannot be used to create the data.
9+
Possible arguments are subset or weights.
10+
11+
# submodel prediction
12+
13+
Code
14+
multi_predict(class_fit, newdata = wa_churn[1:4, vars], trees = 4, type = "prob")
15+
Condition
16+
Error in `multi_predict()`:
17+
! Please use `new_data` instead of `newdata`.
18+
19+
# argument checks for data dimensions
20+
21+
Code
22+
f_fit <- fit(spec, species ~ ., data = penguins)
23+
Condition
24+
Warning:
25+
! 1000 samples were requested but there were 333 rows in the data.
26+
i 333 will be used.
27+
28+
---
29+
30+
Code
31+
xy_fit <- fit_xy(spec, x = penguins[, -1], y = penguins$species)
32+
Condition
33+
Warning:
34+
! 1000 samples were requested but there were 333 rows in the data.
35+
i 333 will be used.
36+
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# xgboost execution, classification
2+
3+
Code
4+
res <- parsnip::fit(hpc_xgboost, class ~ novar, data = hpc, control = ctrl)
5+
Condition
6+
Error:
7+
! object 'novar' not found
8+
9+
# submodel prediction
10+
11+
Code
12+
multi_predict(class_fit, newdata = wa_churn[1:4, vars], trees = 5, type = "prob")
13+
Condition
14+
Error in `multi_predict()`:
15+
! Please use `new_data` instead of `newdata`.
16+
17+
# validation sets
18+
19+
Code
20+
reg_fit <- fit(set_engine(boost_tree(trees = 20, mode = "regression"),
21+
"xgboost", validation = 3), mpg ~ ., data = mtcars[-(1:4), ])
22+
Condition
23+
Error in `parsnip::xgb_train()`:
24+
! `validation` should be on [0, 1).
25+
26+
# early stopping
27+
28+
Code
29+
reg_fit <- fit(set_engine(boost_tree(trees = 20, stop_iter = 30, mode = "regression"),
30+
"xgboost", validation = 0.1), mpg ~ ., data = mtcars[-(1:4), ])
31+
Condition
32+
Warning:
33+
`early_stop` was reduced to 19.
34+
35+
---
36+
37+
Code
38+
reg_fit <- fit(set_engine(boost_tree(trees = 20, stop_iter = 0, mode = "regression"),
39+
"xgboost", validation = 0.1), mpg ~ ., data = mtcars[-(1:4), ])
40+
Condition
41+
Error in `parsnip::xgb_train()`:
42+
! `early_stop` should be on [2, 20).
43+
44+
# xgboost data conversion
45+
46+
Code
47+
from_df <- parsnip:::as_xgb_data(mtcar_x, mtcars_y, event_level = "second")
48+
Condition
49+
Warning:
50+
`event_level` can only be set for binary outcomes.
51+
52+
# argument checks for data dimensions
53+
54+
Code
55+
f_fit <- fit(spec, species ~ ., data = penguins, control = ctrl)
56+
Condition
57+
Warning:
58+
! 1000 samples were requested but there were 333 rows in the data.
59+
i 333 will be used.
60+
61+
---
62+
63+
Code
64+
xy_fit <- fit_xy(spec, x = penguins_dummy, y = penguins$species, control = ctrl)
65+
Condition
66+
Warning:
67+
! 1000 samples were requested but there were 333 rows in the data.
68+
i 333 will be used.
69+
70+
# count/proportion parameters
71+
72+
Code
73+
fit(set_mode(set_engine(boost_tree(mtry = 0.9, trees = 4), "xgboost"),
74+
"regression"), mpg ~ ., data = mtcars)
75+
Condition
76+
Error in `xgb_train()`:
77+
! The option `counts = TRUE` was used but `colsample_bynode` was given as 0.9.
78+
i Please use a value >= 1 or use `counts = FALSE`.
79+
80+
# interface to param arguments
81+
82+
! Please supply elements of the `params` list argument as main arguments to `set_engine()` rather than as part of `params`.
83+
i See `?details_boost_tree_xgboost` for more information.
84+
85+
---
86+
87+
! Please supply elements of the `params` list argument as main arguments to `set_engine()` rather than as part of `params`.
88+
i See `?details_boost_tree_xgboost` for more information.
89+
90+
---
91+
92+
! The argument `watchlist` is guarded by parsnip and will not be passed to `xgb.train()`.
93+
94+
---
95+
96+
! The arguments `watchlist` and `data` are guarded by parsnip and will not be passed to `xgb.train()`.
97+
98+
---
99+
100+
! Please supply elements of the `params` list argument as main arguments to `set_engine()` rather than as part of `params`.
101+
i See `?details_boost_tree_xgboost` for more information.
102+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# numeric y and mixed x, fail missing data
2+
3+
Code
4+
.convert_form_to_xy_fit(rate ~ ., data = Puromycin_miss, na.action = na.fail,
5+
indicators = "traditional", remove_intercept = TRUE)
6+
Condition
7+
Error in `na.fail.default()`:
8+
! missing values in object
9+
10+
# numeric x and factor y
11+
12+
Code
13+
expected <- glm(class ~ ., data = hpc, x = TRUE, y = TRUE, family = binomial())
14+
Condition
15+
Warning:
16+
glm.fit: fitted probabilities numerically 0 or 1 occurred
17+
18+
# bad args
19+
20+
Code
21+
.convert_form_to_xy_fit(mpg ~ ., data = mtcars, composition = "tibble",
22+
indicators = "traditional", remove_intercept = TRUE)
23+
Condition
24+
Error:
25+
! `composition` should be either "data.frame", "matrix", or "dgCMatrix".
26+
27+
---
28+
29+
Code
30+
.convert_form_to_xy_fit(mpg ~ ., data = mtcars, weights = letters[1:nrow(mtcars)],
31+
indicators = "traditional", remove_intercept = TRUE)
32+
Condition
33+
Error:
34+
! `weights` must be a numeric vector.
35+
36+
---
37+
38+
Code
39+
.convert_xy_to_form_fit(mtcars$disp, mtcars$mpg, remove_intercept = TRUE)
40+
Condition
41+
Error:
42+
! `x` cannot be a vector.
43+
44+
---
45+
46+
Code
47+
.convert_xy_to_form_fit(mtcars[, 1:3], mtcars[, 2:5], remove_intercept = TRUE)
48+
Condition
49+
Error in `.convert_xy_to_form_fit()`:
50+
! `x` and `y` have the names "cyl" and "disp" in common.
51+
i Please ensure that `x` and `y` don't share any column names.
52+
53+
# convert to matrix
54+
55+
Code
56+
parsnip::maybe_matrix(ames[, c("Year_Built", "Neighborhood")])
57+
Condition
58+
Error in `parsnip::maybe_matrix()`:
59+
! The column "Neighborhood" is non-numeric, so the data cannot be converted to a numeric matrix.
60+
61+
---
62+
63+
Code
64+
parsnip::maybe_matrix(Chicago[, c("ridership", "date")])
65+
Condition
66+
Error in `parsnip::maybe_matrix()`:
67+
! The column "date" is non-numeric, so the data cannot be converted to a numeric matrix.
68+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# updating
2+
3+
Code
4+
update(set_engine(decision_tree(cost_complexity = 0.1), "rpart", model = FALSE),
5+
cost_complexity = tune(), model = tune())
6+
Output
7+
Decision Tree Model Specification (unknown mode)
8+
9+
Main Arguments:
10+
cost_complexity = tune()
11+
12+
Engine-Specific Arguments:
13+
model = tune()
14+
15+
Computational engine: rpart
16+
17+
18+
# bad input
19+
20+
"bogus" is not a known mode for model `decision_tree()`.
21+
22+
---
23+
24+
Please set the mode in the model specification (`?parsnip::model_spec()`).
25+
26+
---
27+
28+
Please set the mode in the model specification (`?parsnip::model_spec()`).
29+
30+
---
31+
32+
Code
33+
try(translate(decision_tree(), engine = NULL), silent = TRUE)
34+
Message
35+
Used `engine = 'rpart'` for translation.
36+
37+
# argument checks for data dimensions
38+
39+
Code
40+
f_fit <- fit(spec, body_mass_g ~ ., data = penguins)
41+
Condition
42+
Warning:
43+
! 1000 samples were requested but there were 333 rows in the data.
44+
i 333 samples will be used.
45+
46+
---
47+
48+
Code
49+
xy_fit <- fit_xy(spec, x = penguins[, -6], y = penguins$body_mass_g)
50+
Condition
51+
Warning:
52+
! 1000 samples were requested but there were 333 rows in the data.
53+
i 333 samples will be used.
54+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# can be temporarily overriden at evaluation time
2+
3+
Code
4+
.cols()
5+
Condition
6+
Error in `descr_env$.cols()`:
7+
! Descriptor context not set
8+

tests/testthat/_snaps/extract.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# extract
2+
3+
Code
4+
extract_spec_parsnip(x_no_spec)
5+
Condition
6+
Error in `extract_spec_parsnip()`:
7+
! The model fit does not have a model spec.
8+
i This is an internal error that was detected in the parsnip package.
9+
Please report it at <https://github.com/tidymodels/parsnip/issues> with a reprex (<https://tidyverse.org/help/>) and the full backtrace.
10+
11+
---
12+
13+
Code
14+
extract_fit_engine(x_no_fit)
15+
Condition
16+
Error in `extract_fit_engine()`:
17+
! The model fit does not have an engine fit.
18+
i This is an internal error that was detected in the parsnip package.
19+
Please report it at <https://github.com/tidymodels/parsnip/issues> with a reprex (<https://tidyverse.org/help/>) and the full backtrace.
20+
21+
# extract parameter set from model with no loaded implementation
22+
23+
Code
24+
extract_parameter_set_dials(bt_mod)
25+
Condition
26+
Error:
27+
! parsnip could not locate an implementation for `bag_tree` regression model specifications.
28+
i The parsnip extension package baguette implements support for this specification.
29+
i Please install (if needed) and load to continue.
30+
31+
---
32+
33+
Code
34+
extract_parameter_dials(bt_mod, parameter = "min_n")
35+
Condition
36+
Error:
37+
! parsnip could not locate an implementation for `bag_tree` regression model specifications.
38+
i The parsnip extension package baguette implements support for this specification.
39+
i Please install (if needed) and load to continue.
40+
41+
# extract single parameter from model with no parameters
42+
43+
Code
44+
extract_parameter_dials(lm_model, parameter = "none there")
45+
Condition
46+
Error in `extract_parameter_dials()`:
47+
! No parameter exists with id "none there".
48+
49+
# extract_fit_time() works
50+
51+
Code
52+
extract_fit_time(lm_fit)
53+
Condition
54+
Error in `extract_fit_time()`:
55+
! This model was fit before `extract_fit_time()` was added.
56+

0 commit comments

Comments
 (0)