我最近一直在使用 TidyModels,想知道它是否具有许多模型的功能,类似于 R For Data Science 的许多模型章节中介绍的 Modelr 中可用的功能。
我浏览了文档,但没有看到这个。
我最近一直在使用 TidyModels,想知道它是否具有许多模型的功能,类似于 R For Data Science 的许多模型章节中介绍的 Modelr 中可用的功能。
我浏览了文档,但没有看到这个。
tidymodels 框架对 modelr 允许您执行的各种任务具有更强大和更具表现力的支持,例如创建数据重采样、管道模型等。broom包是tidymodels 的一部分,带有动词 liketidy()
和glance()
tidymodels 方法的重要部分建模,并且rsample包提供了重新采样的工具。
您可能有兴趣了解如何使用这种方法对模型参数进行引导估计:
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 包于 2020-06-18 创建(v0.3.0.9001)
如果您对创建模型参数网格感兴趣,请查看dials包。