Hello world! I am starting to like tidymodels. It gives me the tidyverse friendly coding styles.
I have a short question.
How do I get the list items of models called by parsnip package? A quick example as followed
library(tidymodels)
# for instance, i want to get "importance" list items by returned randomForest::randomForest
original.model <- randomForest::randomForest(Species ~ ., data=iris, ntree=1000, mtry=2, importance=TRUE)
original.model$importance
importance(original.model)
varImpPlot(original.model)
# setosa versicolor
# Sepal.Length 0.0333 0.02056
# Sepal.Width 0.0078 0.00283
# Petal.Length 0.3289 0.30913
# Petal.Width 0.3316 0.30632
# virginica
# Sepal.Length 0.04028
# Sepal.Width 0.00946
# Petal.Length 0.29844
# Petal.Width 0.26959
# from all the possible list items
names(original.model)
#> [1] "call" "type" "predicted"
#> [4] "err.rate" "confusion" "votes"
#> [7] "oob.times" "classes" "importance"
#> [10] "importanceSD" "localImportance" "proximity"
#> [13] "ntree" "mtry" "forest"
#> [16] "y" "test" "inbag"
#> [19] "terms"
parsnip.model <- rand_forest(mode='classification', mtry=2, trees=1000) %>%
set_engine('randomForest', importance=TRUE) %>%
fit(Species ~ ., data=iris)
# how do I get the list items as above?
names(parsnip.model)
#> [1] "lvl" "spec" "fit" "preproc"