Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/romainfrancois/hybrid
Playground for hybrid evaluation
https://github.com/romainfrancois/hybrid
Last synced: 12 days ago
JSON representation
Playground for hybrid evaluation
- Host: GitHub
- URL: https://github.com/romainfrancois/hybrid
- Owner: romainfrancois
- License: other
- Created: 2019-10-03T14:01:42.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-06-28T13:43:18.000Z (over 1 year ago)
- Last Synced: 2024-11-26T22:13:16.802Z (16 days ago)
- Language: R
- Size: 9.77 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - romainfrancois/hybrid - Playground for hybrid evaluation (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# hybridThe goal of hybrid is to ...
## Installation
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("romainfrancois/hybrid")
```
## Motivation`eval_hybrid()` (temporary name) evaluates an expression with `eval_tidy()` with a data mask
made of hybrid leaves. An hybrid leaf is essentially the `ptype` of a column marked with the
`"hybrid"` class.Giving leaves the hybrid class makes it possible to dispatch based on that class, so `mean.hybrid`
and `+.hybrid` (currently for this POC) when passed hybrid trees (leaves included) make hybrid trees.```{r}
library(hybrid)eval_hybrid(iris, mean(Sepal.Length))
```For functions that don't define hybrid methods, the computation is however as quick as possible
yet still maintaining some type stability because the ptype is used in place of the real column.```{r}
eval_hybrid(iris, median(Sepal.Length))
```The idea is that standard R evaluation and dispatch takes place and if we end up with an hybrid object,
then perhaps the c++ code can handle it, otherwise fall back.```{r}
# these return an hybrid object because +() and mean() can handle hybrid
eval_hybrid(iris, mean(Sepal.Length))
eval_hybrid(iris, Sepal.Length + Sepal.Width)
eval_hybrid(iris, Sepal.Length + Sepal.Width + Petal.Length)
eval_hybrid(iris, mean(Sepal.Length + Sepal.Width))# not sensible to the call ast, as is evaluation based
plus <- function(x, y) {
x + y
}eval_hybrid(iris, identity(mean(Sepal.Length)))
eval_hybrid(iris, plus(Sepal.Length, Sepal.Width))# No max() hybrid function so we get something not hybrid
eval_hybrid(iris, mad(Sepal.Length))# + does not handle the pattern `hybrid + not-hybrid`
eval_hybrid(iris, mean(Sepal.Length) + 1)
```