我最近一直在使用TidyModels,并且想知道它是否具有用于Many Models的功能,类似于R For Data Science的Many Models一章中介绍的Modelr中可用的功能。
我已经阅读了文档,但没有看到。
答案 0 :(得分:2)
tidymodels框架对建模器允许您执行的各种任务提供了更健壮和更具表现力的支持,例如创建数据重采样,管道模型等。broom包是part of tidymodels并带有动词像tidy()
和glance()
这样的tidymodels方法建模的重要部分,而rsample包提供了用于重采样的工具。
您可能对checking out how to use this kind of approach for bootstrap estimates of model parameters感兴趣:
library(tidymodels)
#> ── Attaching packages ──────────────────────────── tidymodels 0.1.0 ──
#> ✓ broom 0.5.6 ✓ recipes 0.1.12
#> ✓ dials 0.0.7 ✓ rsample 0.0.7
#> ✓ dplyr 1.0.0 ✓ tibble 3.0.1
#> ✓ ggplot2 3.3.1 ✓ tune 0.1.0
#> ✓ infer 0.5.2 ✓ workflows 0.1.1.9000
#> ✓ parsnip 0.1.1.9000 ✓ yardstick 0.0.6.9000
#> ✓ purrr 0.3.4
#> ── Conflicts ─────────────────────────────── tidymodels_conflicts() ──
#> x purrr::discard() masks scales::discard()
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag() masks stats::lag()
#> x recipes::step() masks stats::step()
library(tidyr)
set.seed(123)
boots <- bootstraps(mtcars, times = 1000, apparent = TRUE)
fit_spline <- function(split) {
data <- analysis(split)
smooth.spline(data$wt, data$mpg, df = 4)
}
boot_models <- boots %>%
mutate(spline = map(splits, fit_spline))
boot_models %>%
sample_n(200) %>%
mutate(aug = map(spline, augment)) %>%
unnest(aug) %>%
ggplot(aes(x, y)) +
geom_line(aes(y = .fitted, group = id), alpha = .2, col = "darkcyan") +
geom_point()
由reprex package(v0.3.0.9001)于2020-06-18创建
如果您有兴趣创建模型参数网格,请查看dials软件包。