@@ -21,33 +21,34 @@ test_that("sparse tibble can be passed to `fit()", {
21
21
)
22
22
})
23
23
24
- test_that(" sparse tibble can be passed to `fit_xy ()" , {
24
+ test_that(" sparse matrix can be passed to `fit ()" , {
25
25
skip_if_not_installed(" xgboost" )
26
26
27
27
hotel_data <- sparse_hotel_rates()
28
- hotel_data <- sparsevctrs :: coerce_to_sparse_tibble(hotel_data )
29
28
30
29
spec <- boost_tree() %> %
31
30
set_mode(" regression" ) %> %
32
31
set_engine(" xgboost" )
33
32
34
33
expect_no_error(
35
- lm_fit <- fit_xy (spec , x = hotel_data [, - 1 ], y = hotel_data [, 1 ] )
34
+ lm_fit <- fit (spec , avg_price_per_room ~ . , data = hotel_data )
36
35
)
37
36
38
37
spec <- linear_reg() %> %
39
38
set_mode(" regression" ) %> %
40
39
set_engine(" lm" )
41
40
42
41
expect_snapshot(
43
- lm_fit <- fit_xy(spec , x = hotel_data [1 : 100 , - 1 ], y = hotel_data [1 : 100 , 1 ])
42
+ error = TRUE ,
43
+ lm_fit <- fit(spec , avg_price_per_room ~ . , data = hotel_data [1 : 100 , ])
44
44
)
45
45
})
46
46
47
- test_that(" sparse matrices can be passed to `fit_xy()" , {
47
+ test_that(" sparse tibble can be passed to `fit_xy()" , {
48
48
skip_if_not_installed(" xgboost" )
49
49
50
50
hotel_data <- sparse_hotel_rates()
51
+ hotel_data <- sparsevctrs :: coerce_to_sparse_tibble(hotel_data )
51
52
52
53
spec <- boost_tree() %> %
53
54
set_mode(" regression" ) %> %
@@ -62,12 +63,11 @@ test_that("sparse matrices can be passed to `fit_xy()", {
62
63
set_engine(" lm" )
63
64
64
65
expect_snapshot(
65
- lm_fit <- fit_xy(spec , x = hotel_data [1 : 100 , - 1 ], y = hotel_data [1 : 100 , 1 ]),
66
- error = TRUE
66
+ lm_fit <- fit_xy(spec , x = hotel_data [1 : 100 , - 1 ], y = hotel_data [1 : 100 , 1 ])
67
67
)
68
68
})
69
69
70
- test_that(" sparse matrices can not be passed to `fit ()" , {
70
+ test_that(" sparse matrices can be passed to `fit_xy ()" , {
71
71
skip_if_not_installed(" xgboost" )
72
72
73
73
hotel_data <- sparse_hotel_rates()
@@ -76,9 +76,17 @@ test_that("sparse matrices can not be passed to `fit()", {
76
76
set_mode(" regression" ) %> %
77
77
set_engine(" xgboost" )
78
78
79
+ expect_no_error(
80
+ lm_fit <- fit_xy(spec , x = hotel_data [, - 1 ], y = hotel_data [, 1 ])
81
+ )
82
+
83
+ spec <- linear_reg() %> %
84
+ set_mode(" regression" ) %> %
85
+ set_engine(" lm" )
86
+
79
87
expect_snapshot(
80
- error = TRUE ,
81
- hotel_fit <- fit( spec , avg_price_per_room ~ . , data = hotel_data )
88
+ lm_fit <- fit_xy( spec , x = hotel_data [ 1 : 100 , - 1 ], y = hotel_data [ 1 : 100 , 1 ]) ,
89
+ error = TRUE
82
90
)
83
91
})
84
92
0 commit comments