Skip to content

Commit

Permalink
rename pred_log_fold() to should_use_sparsity()
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed Jan 17, 2025
1 parent c13d98e commit 96e1349
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions R/sparsevctrs.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@ toggle_sparsity <- function(object, data) {
extract_preprocessor(object)
)

pred_log_fold <- pred_log_fold(
toggle_sparse <- should_use_sparsity(
est_sparsity,
extract_spec_parsnip(object)$engine,
nrow(data)
)

toggle_sparse <- "no"

if (pred_log_fold > 0) {
toggle_sparse <- "yes"
}

object$pre$actions$recipe$recipe <- recipes::.recipes_toggle_sparse_args(
object$pre$actions$recipe$recipe,
choice = toggle_sparse
Expand All @@ -40,9 +34,9 @@ allow_sparse <- function(x) {
all(res$allow_sparse_x[res$engine == x$engine])
}

pred_log_fold <- function(sparsity, model, n_rows) {
should_use_sparsity <- function(sparsity, model, n_rows) {
if (is.null(model) || model == "ranger") {
return(-Inf)
return("no")
}

log_fold <- -0.599333138645995 +
Expand Down Expand Up @@ -76,5 +70,5 @@ pred_log_fold <- function(sparsity, model, n_rows) {
-5.39592564852111
}

log_fold
ifelse(log_fold > 0, "yes", "no")
}

0 comments on commit 96e1349

Please sign in to comment.