usemethod中的错误(“ filtr”):没有适用的方法' filter'应用于“ null”类的对象

发布于 2025-02-11 19:29:02 字数 1581 浏览 2 评论 0原文

实际上,我正在使用R上的Tidymodels软件包来研究多类分类问题。我已经使用工作流集培训了几个型号,在我的食谱中,我添加了一个步骤那里用常数替换NA值。我在工作流中包含的模型是:

mlp <-
  mlp(hidden_units = tune(), penalty = tune(), epochs = tune()) %>%
  set_engine('nnet') %>%
  set_mode('classification')

multinom <-
  multinom_reg(penalty = tune(), mixture = tune()) %>%
  set_engine('glmnet')

rand_forest <-
  rand_forest(mtry = tune(), min_n = tune()) %>%
  set_engine('ranger') %>%
  set_mode('classification')

tabnet <- tabnet(mode="classification", batch_size= 126, virtual_batch_size= 128, epochs= 1,
                 num_steps = tune(), learn_rate = tune())%>%
  set_engine("torch", verbose = TRUE)

对于某些型号,我尝试了使用Smote(“ Themis”软件包),PCA和归一化的食谱(通过将步骤添加到原始食谱中)。培训和测试进行得很好,因此我尝试了这些模型的合奏(使用软件包“堆栈”):

  tidymodels_prefer()
  
    stack1 <- 
    stacks() %>% 
    add_candidates(res_1)
  
 
  set.seed(2002)
   res1_stack <-
     stack1 %>%
    blend_predictions()

ens <- fit_members(res1_stack)

当我运行最后一个操作(fit_members)时,我会收到

Error in UseMethod("filter") : 
  no applicable method for 'filter' applied to an object of class "NULL"

我发现的这个错误,读取 this 在github上,这是因为在配方中添加的步骤“ constandImpute”。但是,我不完全知道该如何解决。有人可以帮我吗?

非常感谢!!!

I am actually using Tidymodels package on R to study a multi-class classification problem. I have trained several models using Workflow sets, and in my recipe I added a step taken there to replace NA values with a constant. The models that I included in the workflow are:

mlp <-
  mlp(hidden_units = tune(), penalty = tune(), epochs = tune()) %>%
  set_engine('nnet') %>%
  set_mode('classification')

multinom <-
  multinom_reg(penalty = tune(), mixture = tune()) %>%
  set_engine('glmnet')

rand_forest <-
  rand_forest(mtry = tune(), min_n = tune()) %>%
  set_engine('ranger') %>%
  set_mode('classification')

tabnet <- tabnet(mode="classification", batch_size= 126, virtual_batch_size= 128, epochs= 1,
                 num_steps = tune(), learn_rate = tune())%>%
  set_engine("torch", verbose = TRUE)

For some models I tried a recipe with SMOTE ("themis" package), PCA, and normalisation (all in the same workflow by adding the steps to the original recipe). Training and testing went pretty well, so I tried an ensemble of these models (using the package "stacks"):

  tidymodels_prefer()
  
    stack1 <- 
    stacks() %>% 
    add_candidates(res_1)
  
 
  set.seed(2002)
   res1_stack <-
     stack1 %>%
    blend_predictions()

ens <- fit_members(res1_stack)

When I run this last operation (fit_members) I receive this error

Error in UseMethod("filter") : 
  no applicable method for 'filter' applied to an object of class "NULL"

I figured out, reading this and this on GitHub, that it was because the added step "constantimpute" to the recipe. However, I don't exactly know how can I fix it. Someone can help me?

Thank you very much!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怀里藏娇 2025-02-18 19:29:02

在使用过滤器功能之前,请确保您要过滤的表已加载。
大多数时候,我们都应用了视图()函数,这会防止表将表加载到内存中以供使用。

Before using the filter function, make sure the table you want to filter is loaded.
Most times we have the the view() function applied and this prevents the table from being loaded into memory for usage.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文