The goal of beetroot is to enable the parsnip package to fit mixture models.
You can install the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("hfrick/beetroot")
This is a basic example of fitting a mixture model and getting predictions:
library(beetroot)
#> Loading required package: parsnip
library(rsample)
#> Loading required package: tidyr
set.seed(403)
data("faithful")
faithful_split <- initial_split(faithful, prop = 0.95)
faithful_train <- training(faithful_split)
faithful_test <- testing(faithful_split)
mm_spec <- mixture_model(components = 2) %>%
set_engine("flexmix")
mm_fit <- mm_spec %>%
fit(eruptions ~ waiting, data = faithful_train)
predict(mm_fit, new_data = faithful_test, type = "numeric")
#> # A tibble: 13 x 1
#> .pred
#> <dbl>
#> 1 4.03
#> 2 1.68
#> 3 1.76
#> 4 2.67
#> 5 3.50
#> 6 3.88
#> 7 2.67
#> 8 4.33
#> 9 3.96
#> 10 2.44
#> 11 5.02
#> 12 4.64
#> 13 2.21
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.