Hi,
I was wondering is it possible to see the results of down sampling in Tidy models
In my example below i have an imbalanced data set, I create a recipe to down sample the majority class but when I bake it, i see the ratio between the classes has not changed. Can anyone help?
library(tidymodels)
library(tidyverse)
# Create a dataframe where we are trying to predict Setosa
mydf <- iris %>%
mutate(set_tgt = factor(ifelse(Species == 'setosa', 'yes', 'no'), levels = c('yes', 'no'))) %>%
select(-Species)
# Initial Table
table(mydf$set_tgt)
#> yes no
#> 50 100
# Try tune the correlation before removal and the sampling ratio
flower_rec <- recipe(set_tgt ~ ., data = mydf) %>%
themis::step_downsample(set_tgt)
# Try to see the downsampling
p <- prep(flower_rec, new_data = mydf)
test <- bake(p, new_data = mydf)
# See the change in the label because of upsampling
table(test$set_tgt)
#> yes no
#> 50 100
Thanks