Chapter 6 Fitting models with parsnip

Learning objectives:

  • Identify ways in which model interfaces can differ. x
  • Specify a model in {parsnip}. x
  • Fit a model with parsnip::fit() and parsnip::fit_xy(). x
  • Describe how {parsnip} generalizes model arguments. x
  • Use broom::tidy() to convert model objects to a tidy structure. x
  • Use dplyr::bind_cols() and the predict() methods from {parsnip} to make tidy predictions.
  • Find interfaces to other models in {parsnip}-adjacent packages.
Modeling Map

modeling flow

  • Chapter Setup Below
# load parsnip, recipes, rsample, broom...
library(tidymodels)
library(AmesHousing)

# attach data
data(ames)

# log scale price
ames <- mutate(ames, Sale_Price = log10(Sale_Price))

# train/test
set.seed(123)
ames_split <- initial_split(ames, prop = 0.80, strata = Sale_Price)
ames_train <- training(ames_split)
ames_test  <-  testing(ames_split)