File tree Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -3,31 +3,32 @@ is_sparse_matrix <- function(x) {
3
3
}
4
4
5
5
toggle_sparsity <- function (object , data ) {
6
- toggle_sparse <- " no"
7
-
8
- if (allow_sparse(expect_spec_parsnip(object ))) {
9
- if (has_preprocessor_recipe(object )) {
10
- est_sparsity <- recipes :: .recipes_estimate_sparsity(
11
- extract_preprocessor(object )
12
- )
13
- } else {
14
- est_sparsity <- sparsevctrs :: sparsity(data , sample = 1000 )
15
- }
6
+ if (
7
+ allow_sparse(object $ fit $ actions $ model $ spec ) &&
8
+ has_preprocessor_recipe(object )
9
+ ) {
10
+ est_sparsity <- recipes :: .recipes_estimate_sparsity(
11
+ extract_preprocessor(object )
12
+ )
16
13
17
14
pred_log_fold <- pred_log_fold(
18
15
est_sparsity ,
19
16
extract_spec_parsnip(object )$ engine ,
20
17
nrow(data )
21
18
)
19
+
20
+ toggle_sparse <- " no"
21
+
22
22
if (pred_log_fold > 0 ) {
23
23
toggle_sparse <- " yes"
24
24
}
25
+
26
+ object $ pre $ actions $ recipe $ recipe <- recipes :: .recipes_toggle_sparse_args(
27
+ object $ pre $ actions $ recipe $ recipe ,
28
+ choice = toggle_sparse
29
+ )
25
30
}
26
31
27
- object $ pre $ actions $ recipe $ recipe <- recipes :: .recipes_toggle_sparse_args(
28
- object $ pre $ actions $ recipe $ recipe ,
29
- choice = toggle_sparse
30
- )
31
32
object
32
33
}
33
34
You can’t perform that action at this time.
0 commit comments