Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add toggle_sparsity() #281

Merged
merged 13 commits into from
Jan 17, 2025
Merged

add toggle_sparsity() #281

merged 13 commits into from
Jan 17, 2025

Conversation

EmilHvitfeldt
Copy link
Member

@EmilHvitfeldt EmilHvitfeldt commented Jan 15, 2025

to close #271

I think this is the last puzzle piece to make sparsity useful in tidymodels.

This will toggle the sparsity creation of recipes based on whether or not we estimate it will be useful or not.

R/sparsevctrs.R Outdated Show resolved Hide resolved
R/sparsevctrs.R Outdated
Comment on lines 43 to 45
if (is.null(model) || model == "ranger") {
return("no")
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-01-15 at 1 32 52 PM

since ranger performs identically for both sparse and dense data, we turn off automatically

Copy link
Contributor

@simonpcouch simonpcouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loving where this is going! Finding the inlined model fit very satisfying😆

I know that we're planning on testing all of the unique combinations of these code paths in extratests, but could we test toggle_sparsity() by itself here as well as one example workflow fit where toggle_sparsity() returns "yes"?

R/sparsevctrs.R Outdated Show resolved Hide resolved
R/sparsevctrs.R Outdated Show resolved Hide resolved
R/sparsevctrs.R Outdated Show resolved Hide resolved
R/sparsevctrs.R Outdated Show resolved Hide resolved
DESCRIPTION Outdated Show resolved Hide resolved
R/sparsevctrs.R Outdated Show resolved Hide resolved
R/sparsevctrs.R Outdated Show resolved Hide resolved
R/sparsevctrs.R Outdated Show resolved Hide resolved
R/sparsevctrs.R Show resolved Hide resolved
R/sparsevctrs.R Outdated Show resolved Hide resolved
Copy link
Contributor

@simonpcouch simonpcouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Just about there, though still would like to the testing comment in my review description resolved.

@EmilHvitfeldt
Copy link
Member Author

843de34 tests toggle_sparsity() by itself
138da29 fits a workflow where the code flows through toggle_sparsity()

Copy link
Contributor

@simonpcouch simonpcouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! Thumbs up from me on merging once you've resolved those test failures.


data("ames", package = "modeldata")

tree_spec <- parsnip::boost_tree("regression", "xgboost")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing:

══ Failed tests ════════════════════════════════════════════════════════════════
── Failure ('test-sparsevctrs.R:294:3'): toggle_sparsity doesn't break fit ─────
Expected `fit(wf_spec, ames)` to run without any errors.
i Actually got a <rlang_error> with text:
  Please install the xgboost package to use this engine.

in tests.

A few of these read skip_if_not_installed("glmnet") but then use an xgboost model spec.

@EmilHvitfeldt EmilHvitfeldt merged commit d963de9 into main Jan 17, 2025
13 of 14 checks passed
@EmilHvitfeldt EmilHvitfeldt deleted the toggle-sparsity branch January 17, 2025 22:06
Copy link

github-actions bot commented Feb 1, 2025

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sparse toggling mechanic
2 participants