-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
99 lines (73 loc) · 2.47 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
output: github_document
format: gfm
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# rinfa
<!-- badges: start -->
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[](https://CRAN.R-project.org/package=rinfa)
[](https://github.com/simonpcouch/rinfa/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The goal of rinfa is to provide Rust bindings for parsnip model specifications.
## Installation
You can install the development version of rinfa from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("simonpcouch/rinfa")
```
## Example
```{r, echo = FALSE, message = FALSE}
# this code just logs the state of the parsnip model environment
# befor eloading rinfa so it can be used in the "Available implementations" sec
library(parsnip)
parsnip_models <- get_from_env("models") %>%
setNames(., .) %>%
purrr::map_dfr(get_from_env, .id = "model")
```
```{r}
x <- matrix(rnorm(3e7), ncol = 3, dimnames = list(NULL, paste0("X", 1:3)))
y <- rnorm(1e7)
dat <- cbind(as.data.frame(x), y)
# the usual formula interface
system.time(
lm(y ~ ., dat)
)
system.time(
# lm()'s speedy friend (still from base R)
.lm.fit(x, y)
)
# rinfa's implementation
library(rinfa)
system.time({
.linfa_linear_reg(x, y)
})
```
To use rinfa with tidymodels, set the modeling engine to `"linfa"`:
```{r}
# using the formula interface:
linfa_fit <- fit(linear_reg(engine = "linfa"), y ~ ., dat)
# using the (more performant, in this case) XY interface:
linfa_fit_xy <- fit_xy(linear_reg(engine = "linfa"), x = x, y = y)
```
## Available implementations
The rinfa package provides an additional engine `"linfa"` for the models in the following table:
```{r, echo = FALSE, message = FALSE}
rinfa_models <- get_from_env("models") %>%
setNames(., .) %>%
purrr::map_dfr(get_from_env, .id = "model")
dplyr::anti_join(
rinfa_models, parsnip_models,
by = c("model", "engine", "mode")
) %>%
knitr::kable()
```
To read more about the design of rinfa, see [`R/README.md`](https://github.com/simonpcouch/rinfa/tree/main/R/README.md).