AlanInglis / vivid

This package is for visualising variable importance and variable interaction.
https://alaninglis.github.io/vivid/
20 stars 2 forks source link

Applicability for tidymodels output e.g. XGBoost #4

Closed viv-analytics closed 10 months ago

viv-analytics commented 1 year ago

Dear @AlanInglis

Thanks for this great package.

Besides compatibility for caret are you planning to support outputs from tidymodels fit-objects?

Below, I've provided a minimal code example.

library(tidymodels)
library(conflicted)
library(palmerpenguins)

conflicts_prefer(palmerpenguins::penguins)

penguins_split <- initial_split(penguins, strata = "species")
penguins_train <- training(penguins_split)

penguins_rec <- 
  recipe(species ~ island + year, data = penguins_train) |> 
  step_integer(all_nominal_predictors(), zero_based = TRUE)

boost_tree_xgboost_spec <-
  boost_tree() %>%
  set_engine('xgboost') %>%
  set_mode('classification')

results <- 
  workflow(preprocessor = penguins_rec,
           spec         = boost_tree_xgboost_spec) |>
  last_fit(penguins_split)