Goal: build a regression model to predict the prices at IKEA Clickhere for data.

Import Data

ikea <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-11-03/ikea.csv')
## New names:
## Rows: 3694 Columns: 14
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (7): name, category, old_price, link, other_colors, short_description, d... dbl
## (6): ...1, item_id, price, depth, height, width lgl (1): sellable_online
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
skimr::skim(ikea)
Data summary
Name ikea
Number of rows 3694
Number of columns 14
_______________________
Column type frequency:
character 7
logical 1
numeric 6
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
name 0 1 3 27 0 607 0
category 0 1 4 36 0 17 0
old_price 0 1 4 13 0 365 0
link 0 1 52 163 0 2962 0
other_colors 0 1 2 3 0 2 0
short_description 0 1 3 63 0 1706 0
designer 0 1 3 1261 0 381 0

Variable type: logical

skim_variable n_missing complete_rate mean count
sellable_online 0 1 0.99 TRU: 3666, FAL: 28

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
…1 0 1.00 1846.50 1066.51 0 923.25 1846.5 2769.75 3693 ▇▇▇▇▇
item_id 0 1.00 48632396.79 28887094.10 58487 20390574.00 49288078.0 70403572.75 99932615 ▇▇▇▇▇
price 0 1.00 1078.21 1374.65 3 180.90 544.7 1429.50 9585 ▇▁▁▁▁
depth 1463 0.60 54.38 29.96 1 38.00 47.0 60.00 257 ▇▃▁▁▁
height 988 0.73 101.68 61.10 1 67.00 83.0 124.00 700 ▇▂▁▁▁
width 589 0.84 104.47 71.13 1 60.00 80.0 140.00 420 ▇▅▂▁▁
data <- ikea %>%
  
    # Treat missing values
    select(-...1, -old_price, -depth) %>%
    na.omit() %>%
  
    # Log transform variables with pos-skewed distribution
    mutate(price = log(price)) %>%
  
  mutate(across(where(is.logical), factor))

Explore Data

Identify good predictors

width

data %>%
    ggplot(aes(price, width)) +
    scale_y_log10() +
    geom_point()

category

data %>%
    ggplot(aes(price, as.factor(category))) +
    geom_boxplot()

short_description

data %>%
  
    # Tokenize title
    unnest_tokens(output = word, input = short_description) %>%
  
    # Calculate avg price per word
    group_by(word) %>%
    summarise(price = mean(price),
              n     = n()) %>%
    ungroup() %>%
  
    filter(n > 10, !str_detect(word, "\\d")) %>%
    slice_max(order_by = price, n = 20) %>%
  
    # Plot
    ggplot(aes(price, fct_reorder(word, price))) +
    geom_point() +
  
    labs(y = "Words in Title")

EDA shortcut

# Step 1: Prepare data
data_binarized_tbl <- data %>%
    select(-sellable_online, -other_colors) %>%
    binarize()

data_binarized_tbl %>% glimpse()
## Rows: 2,591
## Columns: 81
## $ `item_id__-Inf_20394152`                                                                                 <dbl> …
## $ item_id__20394152_49286341                                                                               <dbl> …
## $ item_id__49286341_70421967                                                                               <dbl> …
## $ item_id__70421967_Inf                                                                                    <dbl> …
## $ name__ALGOT                                                                                              <dbl> …
## $ name__BEKANT                                                                                             <dbl> …
## $ name__BESTÅ                                                                                              <dbl> …
## $ `name__BILLY_/_OXBERG`                                                                                   <dbl> …
## $ name__BRIMNES                                                                                            <dbl> …
## $ name__BROR                                                                                               <dbl> …
## $ name__EKET                                                                                               <dbl> …
## $ name__GRÖNLID                                                                                            <dbl> …
## $ name__HAVSTA                                                                                             <dbl> …
## $ name__HEMNES                                                                                             <dbl> …
## $ name__IVAR                                                                                               <dbl> …
## $ name__JONAXEL                                                                                            <dbl> …
## $ name__KALLAX                                                                                             <dbl> …
## $ name__LIDHULT                                                                                            <dbl> …
## $ name__LIXHULT                                                                                            <dbl> …
## $ name__NORDLI                                                                                             <dbl> …
## $ name__PAX                                                                                                <dbl> …
## $ name__PLATSA                                                                                             <dbl> …
## $ `name__STUVA_/_FRITIDS`                                                                                  <dbl> …
## $ name__TROFAST                                                                                            <dbl> …
## $ name__VALLENTUNA                                                                                         <dbl> …
## $ name__VIMLE                                                                                              <dbl> …
## $ `name__-OTHER`                                                                                           <dbl> …
## $ category__Bar_furniture                                                                                  <dbl> …
## $ category__Beds                                                                                           <dbl> …
## $ `category__Bookcases_&_shelving_units`                                                                   <dbl> …
## $ `category__Cabinets_&_cupboards`                                                                         <dbl> …
## $ category__Chairs                                                                                         <dbl> …
## $ `category__Chests_of_drawers_&_drawer_units`                                                             <dbl> …
## $ `category__Children's_furniture`                                                                         <dbl> …
## $ category__Nursery_furniture                                                                              <dbl> …
## $ category__Outdoor_furniture                                                                              <dbl> …
## $ `category__Sofas_&_armchairs`                                                                            <dbl> …
## $ `category__Tables_&_desks`                                                                               <dbl> …
## $ category__Trolleys                                                                                       <dbl> …
## $ `category__TV_&_media_furniture`                                                                         <dbl> …
## $ category__Wardrobes                                                                                      <dbl> …
## $ `category__-OTHER`                                                                                       <dbl> …
## $ `price__-Inf_5.57972982598622`                                                                           <dbl> …
## $ price__5.57972982598622_6.45362499889269                                                                 <dbl> …
## $ price__6.45362499889269_7.34277918933185                                                                 <dbl> …
## $ price__7.34277918933185_Inf                                                                              <dbl> …
## $ `link__https://www.ikea.com/sa/en/p/norraker-norraker-bar-table-and-2-bar-stools-black-black-s79241940/` <dbl> …
## $ `link__-OTHER`                                                                                           <dbl> …
## $ `short_description__3-seat_sofa`                                                                         <dbl> …
## $ short_description__Armchair                                                                              <dbl> …
## $ short_description__Chair                                                                                 <dbl> …
## $ `short_description__Door,__________60x64_cm`                                                             <dbl> …
## $ `short_description__Table,__________120x60_cm`                                                           <dbl> …
## $ `short_description__Table,__________150x75_cm`                                                           <dbl> …
## $ `short_description__-OTHER`                                                                              <dbl> …
## $ designer__Carina_Bengs                                                                                   <dbl> …
## $ designer__Ebba_Strandmark                                                                                <dbl> …
## $ designer__Ehlén_Johansson                                                                                <dbl> …
## $ `designer__Ehlén_Johansson/IKEA_of_Sweden`                                                               <dbl> …
## $ designer__Francis_Cayouette                                                                              <dbl> …
## $ designer__Henrik_Preutz                                                                                  <dbl> …
## $ designer__IKEA_of_Sweden                                                                                 <dbl> …
## $ `designer__IKEA_of_Sweden/Ehlén_Johansson`                                                               <dbl> …
## $ `designer__IKEA_of_Sweden/Jon_Karlsson`                                                                  <dbl> …
## $ designer__Johan_Kroon                                                                                    <dbl> …
## $ designer__Jon_Karlsson                                                                                   <dbl> …
## $ `designer__K_Hagberg/M_Hagberg`                                                                          <dbl> …
## $ designer__Marcus_Arvonen                                                                                 <dbl> …
## $ designer__Nike_Karlsson                                                                                  <dbl> …
## $ designer__Ola_Wihlborg                                                                                   <dbl> …
## $ designer__Studio_Copenhagen                                                                              <dbl> …
## $ designer__Tord_Björklund                                                                                 <dbl> …
## $ `designer__-OTHER`                                                                                       <dbl> …
## $ `height__-Inf_70`                                                                                        <dbl> …
## $ height__70_83                                                                                            <dbl> …
## $ height__83_127                                                                                           <dbl> …
## $ height__127_Inf                                                                                          <dbl> …
## $ `width__-Inf_60`                                                                                         <dbl> …
## $ width__60_80                                                                                             <dbl> …
## $ width__80_150                                                                                            <dbl> …
## $ width__150_Inf                                                                                           <dbl> …
# Step 2: Correlate
data_corr_tbl <- data_binarized_tbl %>%
    correlate(price__7.34277918933185_Inf)
## Warning: Expected 2 pieces. Additional pieces discarded in 3 rows [52, 53, 54].
data_corr_tbl
## # A tibble: 81 × 3
##    feature  bin                               correlation
##    <fct>    <chr>                                   <dbl>
##  1 price    7.34277918933185_Inf                    1    
##  2 width    150_Inf                                 0.546
##  3 width    -Inf_60                                -0.389
##  4 price    -Inf_5.57972982598622                  -0.334
##  5 price    6.45362499889269_7.34277918933185      -0.333
##  6 price    5.57972982598622_6.45362499889269      -0.332
##  7 category Sofas_&_armchairs                       0.317
##  8 height   -Inf_70                                -0.299
##  9 name     PAX                                     0.279
## 10 category Wardrobes                               0.267
## # ℹ 71 more rows
# Step 3: Plot
data_corr_tbl %>%
    plot_correlation_funnel()
## Warning: ggrepel: 56 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps

Build Models

Split data

# Split into train and test dataset
set.seed(1234)
data_split <- rsample::initial_split(data)
data_train <- training(data_split)
data_test  <- testing(data_split)

# Further split training dataset for cross-validation
set.seed(2345)
data_cv <- rsample::vfold_cv(data_train)
data_cv
## #  10-fold cross-validation 
## # A tibble: 10 × 2
##    splits             id    
##    <list>             <chr> 
##  1 <split [1748/195]> Fold01
##  2 <split [1748/195]> Fold02
##  3 <split [1748/195]> Fold03
##  4 <split [1749/194]> Fold04
##  5 <split [1749/194]> Fold05
##  6 <split [1749/194]> Fold06
##  7 <split [1749/194]> Fold07
##  8 <split [1749/194]> Fold08
##  9 <split [1749/194]> Fold09
## 10 <split [1749/194]> Fold10
library(usemodels)
usemodels::use_xgboost(price ~ ., data = data_train)
## xgboost_recipe <- 
##   recipe(formula = price ~ ., data = data_train) %>% 
##   step_zv(all_predictors()) 
## 
## xgboost_spec <- 
##   boost_tree(trees = tune(), min_n = tune(), tree_depth = tune(), learn_rate = tune(), 
##     loss_reduction = tune(), sample_size = tune()) %>% 
##   set_mode("classification") %>% 
##   set_engine("xgboost") 
## 
## xgboost_workflow <- 
##   workflow() %>% 
##   add_recipe(xgboost_recipe) %>% 
##   add_model(xgboost_spec) 
## 
## set.seed(42752)
## xgboost_tune <-
##   tune_grid(xgboost_workflow, resamples = stop("add your rsample object"), grid = stop("add number of candidate points"))
# Specify recipe
xgboost_recipe <-
  recipe(formula = price ~ ., data = data_train) %>%
  recipes::update_role(item_id, new_role = "ID") %>%
  step_tokenize(name) %>%
  step_tokenfilter(name, max_tokens = 100) %>%
  step_tfidf(name) %>%
  step_other(designer) %>%
  step_dummy(category, sellable_online, other_colors, designer) %>%
  step_log(width, height, price)

xgboost_recipe %>% prep() %>% juice() %>% glimpse()
## Rows: 1,943
## Columns: 125
## $ item_id                                       <dbl> 39251926, 59248867, 3034…
## $ link                                          <fct> https://www.ikea.com/sa/…
## $ short_description                             <fct> "Armchair, in/outdoor,  …
## $ height                                        <dbl> 4.499810, 4.094345, 3.68…
## $ width                                         <dbl> 4.584967, 4.941642, 3.09…
## $ price                                         <dbl> 1.961025, 1.850504, 1.36…
## $ tfidf_name_2017                               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_adde                               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_adils                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_alex                               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_algot                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_äpplarö                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_backaryd                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_bekant                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_bernhard                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_bestå                              <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_billy                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_bottna                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_brimnes                            <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_bror                               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_brusali                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_busunge                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_delaktig                           <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_ekedalen                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_eket                               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_elvarli                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_flottebo                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_franklin                           <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_fritids                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_galant                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_glassvik                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_godishus                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_godvin                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_grönlid                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_hällan                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_hanviken                           <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_havsta                             <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_havsten                            <dbl> 4.807601, 0.000000, 0.00…
## $ tfidf_name_hemnes                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_henriksdal                         <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_hyllis                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_idåsen                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_ikea                               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_ingatorp                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_ingolf                             <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_ivar                               <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_janinge                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_jonaxel                            <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_kallax                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_kallviken                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_kivik                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_klimpen                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_kolbjörn                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_krille                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_kungsholmen                        <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_landskrona                         <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_langur                             <dbl> 0.000000, 0.000000, 5.17…
## $ tfidf_name_lappviken                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_leifarne                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_lerberg                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_lerhamn                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_liatorp                            <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_lidhult                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_linnmon                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_lisabo                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_lixhult                            <dbl> 0.000000, 4.538216, 0.00…
## $ tfidf_name_lycksele                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_malm                               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_mammut                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_melltorp                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_möckelby                           <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_mörbylånga                         <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_morliden                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_nisse                              <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_nordli                             <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_nordviken                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_norråker                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_norraryd                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_norsborg                           <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_notviken                           <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_odger                              <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_oxberg                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_pax                                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_platsa                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_poäng                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_ps                                 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_råskog                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_selsviken                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_själland                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_släkt                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_smågöra                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_söderhamn                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_sollerön                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_songesand                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_stuva                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_sundvik                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_svalnäs                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_svenbertil                         <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_timmerviken                        <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_trofast                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_tyssedal                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_vallentuna                         <dbl> 0.000000, 0.000000, 0.00…
## $ tfidf_name_vimle                              <dbl> 0.00000, 0.00000, 0.0000…
## $ tfidf_name_vittsjö                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_volfgang                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ tfidf_name_ypperlig                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ category_Beds                                 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ category_Bookcases...shelving.units           <dbl> 0, 0, 0, 1, 0, 0, 0, 0, …
## $ category_Cabinets...cupboards                 <dbl> 0, 1, 0, 0, 0, 0, 0, 0, …
## $ category_Café.furniture                       <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ category_Chairs                               <dbl> 1, 0, 1, 0, 0, 0, 0, 1, …
## $ category_Chests.of.drawers...drawer.units     <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ category_Children.s.furniture                 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ category_Nursery.furniture                    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ category_Outdoor.furniture                    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ category_Room.dividers                        <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ category_Sideboards..buffets...console.tables <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ category_Sofas...armchairs                    <dbl> 0, 0, 0, 0, 0, 1, 0, 0, …
## $ category_Tables...desks                       <dbl> 0, 0, 0, 0, 1, 0, 0, 0, …
## $ category_Trolleys                             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ category_TV...media.furniture                 <dbl> 0, 0, 0, 0, 0, 0, 1, 0, …
## $ category_Wardrobes                            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, …
## $ sellable_online_TRUE.                         <dbl> 1, 1, 1, 1, 1, 1, 1, 1, …
## $ other_colors_Yes                              <dbl> 0, 1, 0, 1, 0, 1, 1, 0, …
## $ designer_other                                <dbl> 1, 1, 1, 1, 1, 1, 1, 1, …
# Specify model
xgboost_spec <-
  boost_tree(trees = tune(), min_n = tune(), mtry = tune(), learn_rate = tune()) %>%
  set_mode("regression") %>%
  set_engine("xgboost")

# Combine recipe and model using workflow
xgboost_workflow <-
  workflow() %>%
  add_recipe(xgboost_recipe) %>%
  add_model(xgboost_spec)
  
# Tune hyperparameters
set.seed(344)
xgboost_tune <-
  tune_grid(xgboost_workflow,
            resamples = data_cv,
            grid = 5)
## i Creating pre-processing data to finalize unknown parameter: mtry
## Warning: package 'xgboost' was built under R version 4.3.3
## → A | error:   Some columns are non-numeric. The data cannot be converted to numeric matrix: 'link', 'short_description'.
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x5
## → B | error:   Cannot find current progress bar for `<environment: 0x000002606b612200>`
## Warning: All models failed. Run `show_notes(.Last.tune.result)` for more
## information.