Skip to content

Commit 3a6033d

Browse files
committed
1 parent e36a9ff commit 3a6033d

File tree

3 files changed

+220
-0
lines changed

3 files changed

+220
-0
lines changed

DESCRIPTION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ License: MIT + file LICENSE
1111
Depends:
1212
tidymodels
1313
Suggests:
14+
baguette,
1415
butcher,
16+
censored,
1517
C50,
1618
dials,
1719
dimRed,
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# message informatively with unknown implementation (tidymodels/parsnip#793)
2+
3+
Code
4+
bag_tree() %>% set_engine("rpart") %>% set_mode("regression")
5+
Message <rlang_message>
6+
! parsnip could not locate an implementation for `bag_tree` regression model specifications using the `rpart` engine.
7+
i The parsnip extension package baguette implements support for this specification.
8+
i Please install (if needed) and load to continue.
9+
Output
10+
Bagged Decision Tree Model Specification (regression)
11+
12+
Main Arguments:
13+
cost_complexity = 0
14+
min_n = 2
15+
16+
Computational engine: rpart
17+
18+
19+
---
20+
21+
Code
22+
bag_tree() %>% set_mode("censored regression")
23+
Message <rlang_message>
24+
! parsnip could not locate an implementation for `bag_tree` censored regression model specifications using the `rpart` engine.
25+
i The parsnip extension package censored implements support for this specification.
26+
i Please install (if needed) and load to continue.
27+
Output
28+
Bagged Decision Tree Model Specification (censored regression)
29+
30+
Main Arguments:
31+
cost_complexity = 0
32+
min_n = 2
33+
34+
Computational engine: rpart
35+
36+
37+
---
38+
39+
Code
40+
bag_tree()
41+
Message <rlang_message>
42+
! parsnip could not locate an implementation for `bag_tree` model specifications using the `rpart` engine.
43+
i The parsnip extension packages censored and baguette implement support for this specification.
44+
i Please install (if needed) and load to continue.
45+
Output
46+
Bagged Decision Tree Model Specification (unknown)
47+
48+
Main Arguments:
49+
cost_complexity = 0
50+
min_n = 2
51+
52+
Computational engine: rpart
53+
54+
55+
---
56+
57+
Code
58+
bag_tree() %>% set_engine("rpart")
59+
Message <rlang_message>
60+
! parsnip could not locate an implementation for `bag_tree` model specifications using the `rpart` engine.
61+
i The parsnip extension packages censored and baguette implement support for this specification.
62+
i Please install (if needed) and load to continue.
63+
Output
64+
Bagged Decision Tree Model Specification (unknown)
65+
66+
Main Arguments:
67+
cost_complexity = 0
68+
min_n = 2
69+
70+
Computational engine: rpart
71+
72+
73+
---
74+
75+
Code
76+
bag_tree() %>% set_mode("censored regression") %>% set_engine("rpart")
77+
Output
78+
Bagged Decision Tree Model Specification (censored regression)
79+
80+
Main Arguments:
81+
cost_complexity = 0
82+
min_n = 2
83+
84+
Computational engine: rpart
85+
86+
87+
---
88+
89+
Code
90+
bag_tree() %>% set_engine("rpart")
91+
Output
92+
Bagged Decision Tree Model Specification (unknown)
93+
94+
Main Arguments:
95+
cost_complexity = 0
96+
min_n = 2
97+
98+
Computational engine: rpart
99+
100+
101+
---
102+
103+
Code
104+
bag_tree() %>% set_mode("regression") %>% set_engine("rpart")
105+
Message <rlang_message>
106+
! parsnip could not locate an implementation for `bag_tree` regression model specifications using the `rpart` engine.
107+
i The parsnip extension package baguette implements support for this specification.
108+
i Please install (if needed) and load to continue.
109+
Output
110+
Bagged Decision Tree Model Specification (regression)
111+
112+
Main Arguments:
113+
cost_complexity = 0
114+
min_n = 2
115+
116+
Computational engine: rpart
117+
118+
119+
---
120+
121+
Code
122+
bag_tree() %>% set_mode("classification") %>% set_engine("C5.0")
123+
Message <rlang_message>
124+
! parsnip could not locate an implementation for `bag_tree` classification model specifications using the `C5.0` engine.
125+
i The parsnip extension package baguette implements support for this specification.
126+
i Please install (if needed) and load to continue.
127+
Output
128+
Bagged Decision Tree Model Specification (classification)
129+
130+
Main Arguments:
131+
cost_complexity = 0
132+
min_n = 2
133+
134+
Computational engine: C5.0
135+
136+
137+
---
138+
139+
Code
140+
bag_tree() %>% set_engine("C5.0")
141+
Output
142+
Bagged Decision Tree Model Specification (unknown)
143+
144+
Main Arguments:
145+
cost_complexity = 0
146+
min_n = 2
147+
148+
Computational engine: C5.0
149+
150+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
test_that('message informatively with unknown implementation (tidymodels/parsnip#793)', {
2+
skip_if(utils::packageVersion("parsnip") < "1.0.2")
3+
4+
library(parsnip)
5+
6+
# one possible extension --------------------------------------------------
7+
# known engine, mode
8+
expect_snapshot(
9+
bag_tree() %>%
10+
set_engine("rpart") %>%
11+
set_mode("regression")
12+
)
13+
14+
# known, uniquely identifying mode
15+
expect_snapshot(
16+
bag_tree() %>%
17+
set_mode("censored regression")
18+
)
19+
20+
# two possible extensions -------------------------------------------------
21+
# all default / unknown
22+
expect_snapshot(
23+
bag_tree()
24+
)
25+
26+
# extension-ambiguous engine
27+
expect_snapshot(
28+
bag_tree() %>%
29+
set_engine("rpart")
30+
)
31+
32+
# inter-extension interactions --------------------------------------------
33+
library(censored)
34+
35+
# do not message -- well-specified spec
36+
expect_snapshot(
37+
bag_tree() %>%
38+
set_mode("censored regression") %>%
39+
set_engine("rpart")
40+
)
41+
42+
# do not message - this could still possibly be a well-specified spec
43+
expect_snapshot(
44+
bag_tree() %>%
45+
set_engine("rpart")
46+
)
47+
48+
# message as before, even though there is now a different possible bag_tree spec
49+
expect_snapshot(
50+
bag_tree() %>%
51+
set_mode("regression") %>%
52+
set_engine("rpart")
53+
)
54+
55+
expect_snapshot(
56+
bag_tree() %>%
57+
set_mode("classification") %>%
58+
set_engine("C5.0")
59+
)
60+
61+
# do not message now that baguette is loaded
62+
library(baguette)
63+
64+
expect_snapshot(
65+
bag_tree() %>%
66+
set_engine("C5.0")
67+
)
68+
})

0 commit comments

Comments
 (0)