我正在使用 tidymodels 方法创建一个随机森林模型。在配方函数中,我收到了这个我根本无法解释的错误/警告,但它必须与创建的汇总变量有关。错误是
There are new levels in a factor: NA
所以,现在我的食谱参数看起来像这样:
era.af.Al_rec <- recipes::recipe(logRR ~., data = era.af.Al_predict) %>%
step_mutate_at(logRR, SubPrName, PrName, Product, AEZ16simple, fn = factor) %>%
update_role(ID, new_role = "ID") %>%
update_role(RR_group, new_role = "ID") %>%
step_other(SubPrName, PrName, Product, AEZ16simple, threshold = 0.01) %>%
step_other(Site.ID, threshold = 0.001) %>%
step_dummy(all_nominal(), -all_outcomes()) %>%
step_downsample(logRR)
era.af.Al_prep <- prep(era.af.Al_rec)
juiced <- juice(era.af.Al_prep)
_prep 调用中弹出错误。