if (!requireNamespace("piececor")) devtools::install_github('brshallo/piececor')
library(dplyr)
set.seed(1234)
x <- seq(.01, 3*pi, pi/100)
y <- sin(x) + rnorm(length(x), sd = 0.25)
xy <- tibble::tibble(x = x, y = y)
xy_dist <- infotheo::discretize(xy)
pcor_value <- function(data){
piececor::piecewise_cors(data, .target = y, x) %>%
piececor::weighted_abs_mean_cors() %>%
{.$value}
}
bench::mark(
mutinfo = infotheo::multiinformation(xy_dist),
distcor = correlation::correlation(xy, method = "distance"),
nns = NNS::NNS.dep(x, y)$Dependence,
nlcor = nlcor::nlcor(x, y, plt = FALSE),
piececor = pcor_value(xy),
# Predictive power score is the most different from notions of correlation
# ... maybe shouldn't be on this list
pps = ppsr::score(xy, x = "x", y = "y", algorithm = "tree")$pps,
check = FALSE,
iterations = 10
)
#> Warning: Some expressions had a GC in every iteration; so filtering is disabled.
#> # A tibble: 6 x 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 mutinfo 369.7us 482.3us 2030. 74.05KB 0
#> 2 distcor 21.45ms 32.77ms 29.2 25.88MB 11.7
#> 3 nns 169.69ms 186.06ms 4.72 109.06MB 1.42
#> 4 nlcor 379.35ms 460.94ms 2.12 2.22MB 2.76
#> 5 piececor 424.05ms 447.29ms 2.18 22.49MB 0
#> 6 pps 1.45s 1.56s 0.620 1.65MB 0
Last active
October 27, 2021 18:07
-
-
Save brshallo/6087347f5572feecbb7fa5cbd5e4a8fa to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment