Skip to content

Commit cee2bb8

Browse files
Merge pull request #1171 from tidymodels/doc-sparse-data
document sparse data usage in parsnip
2 parents eba5762 + 9a74d3a commit cee2bb8

25 files changed

+166
-0
lines changed

R/sparsevctrs.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
#' Using sparse data with parsnip
2+
#'
3+
#' You can figure out whether a given model engine supports sparse data by
4+
#' calling `get_encoding("name of model")` and looking at the `allow_sparse_x`
5+
#' column.
6+
#'
7+
#' Using sparse data for model fitting and prediction shouldn't require any
8+
#' additional configurations. Just pass in a sparse matrix such as dgCMatrix
9+
#' from the `Matrix` package or a sparse tibble from the sparsevctrs package
10+
#' to the data argument of [fit()], [fit_xy()], and [predict()].
11+
#'
12+
#' Models that don't support sparse data will try to convert to non-sparse data
13+
#' with warnings. If conversion isn’t possible, an informative error will be
14+
#' thrown.
15+
#'
16+
#' @name sparse_data
17+
NULL
18+
119
to_sparse_data_frame <- function(x, object, call = rlang::caller_env()) {
220
if (is_sparse_matrix(x)) {
321
if (allow_sparse(object)) {

_pkgdown.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ reference:
9090
- set_engine
9191
- set_mode
9292
- show_engines
93+
- sparse_data
9394
- tidy.model_fit
9495
- translate
9596
- starts_with("update")

man/details_boost_tree_xgboost.Rd

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_linear_reg_glmnet.Rd

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_logistic_reg_LiblineaR.Rd

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_logistic_reg_glmnet.Rd

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_multinom_reg_glmnet.Rd

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_rand_forest_ranger.Rd

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_svm_linear_LiblineaR.Rd

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rmd/boost_tree_xgboost.Rmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ For classification, non-numeric outcomes (i.e., factors) are internally converte
6565
```{r child = "template-uses-case-weights.Rmd"}
6666
```
6767

68+
## Sparse Data
69+
70+
```{r child = "template-uses-sparse-data.Rmd"}
71+
```
72+
6873
## Other details
6974

7075
### Interfacing with the `params` argument

0 commit comments

Comments
 (0)