rsample中group_bootstraps比bootstraps慢约2000倍的原因是什么?
关于rsample包中group_bootstraps与bootstraps性能差异的问题
R语言的rsample包包含bootstraps()函数和支持数据分组抽样的group_bootstraps()函数,但实际测试发现group_bootstraps()的运行速度比bootstraps()慢约2000倍,这远超出了仅会稍慢的预期,无法理解差异为何如此巨大。(测试用例中的分组无实际意义,但不影响两个函数的速度对比测试。)
测试代码
library(tidyverse) library(rsample) dat <- tibble(x = 1:1000) microbenchmark::microbenchmark( grouped = { dat %>% group_bootstraps(group = x, times = 10)}, simple = { dat %>% bootstraps(times = 10)}, times = 5)
速度测试结果

内容的提问来源于stack exchange,提问作者PalimPalim
相关产品推荐
相关产品推荐

