# NOT RUN {
library(recipes)
library(modeldata)
data(credit_data)
sort(table(credit_data$Status, useNA = "always"))
ds_rec <- recipe(Status ~ Age + Income + Assets, data = credit_data) %>%
step_meanimpute(all_predictors()) %>%
step_smote(Status) %>%
prep()
sort(table(juice(ds_rec)$Status, useNA = "always"))
# since `skip` defaults to TRUE, baking the step has no effect
baked_okc <- bake(ds_rec, new_data = credit_data)
table(baked_okc$Status, useNA = "always")
ds_rec2 <- recipe(Status ~ Age + Income + Assets, data = credit_data) %>%
step_meanimpute(all_predictors()) %>%
step_smote(Status, over_ratio = 0.2) %>%
prep()
table(juice(ds_rec2)$Status, useNA = "always")
library(ggplot2)
ggplot(circle_example, aes(x, y, color = class)) +
geom_point() +
labs(title = "Without SMOTE")
recipe(class ~ ., data = circle_example) %>%
step_smote(class) %>%
prep() %>%
juice() %>%
ggplot(aes(x, y, color = class)) +
geom_point() +
labs(title = "With SMOTE")
# }
Run the code above in your browser using DataLab