You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用step_downsample函数时出现“找不到该函数”错误的技术求助

解决step_downsample函数找不到的问题

可能的原因及对应解决方法

1. 检查themis包版本

step_downsample是themis包中的函数,旧版本的themis可能未包含该函数。请执行以下命令更新至最新版本:

# 从CRAN更新正式版
update.packages("themis")

# 若CRAN版本仍存在问题,安装GitHub开发版(需先安装devtools)
# install.packages("devtools")
devtools::install_github("tidymodels/themis")

2. 确认包已正确加载

重新加载recipes和themis包,避免加载冲突或未成功加载的情况:

library(recipes)
library(themis)

# 查看themis版本,确保版本在0.1.5及以上
packageVersion("themis")

3. 修正代码拼写错误

你的代码中affiars_recipe存在拼写错误(多了一个字母i),虽然这不是当前报错的直接原因,但后续可能引发其他问题,建议修正为:

affairs_recipe <- recipe( affair ~ ., data = affairs_train) %>% 
  step_downsample(affair) %>%
  step_dummy(all_nominal_predictors()) %>% 
  step_normalize(all_predictors()) %>% 
  prep()

内容的提问来源于stack exchange,提问作者ZRC

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 05:15:41