r - 在带有 tidymodels 的 r 中:警告消息:“所有模型在 [fit_resamples()] 中均失败。请参阅 `.notes` 列。” 内部:错误:在指标中:`roc_auc`
问题描述
我是 R 新手,正在尝试学习 tidymodels。
我只在for 中收到此错误,如果 I & recipe then运行良好,但随后我开始在.glm
iris dataset
change dataset
glm
kknn
Warning message:
"All models failed in [fit_resamples()]. See the `.notes` column."
Warning message:
"This tuning result has notes. Example notes on model fitting include:
internal: Error: In metric: `roc_auc`
我检查了一下.notes
,这就是它的样子:
.notes
<chr>
internal: Error: In metric: `roc_auc`
A tibble: 1 × 1 .notes
<chr>
internal: Error: In metric: `roc_auc`
A tibble: 1 × 1
警告消息:所有模型在 [fit_resamples()] 中均失败。请参阅 `.notes` 列
正如上面帖子中所建议的,我尝试从 github升级parsnip
和包,但安装时出错:tune
tune package
Warning in install.packages : package ‘tune’ is not available for this version of R
我不确定是什么问题,如果有人可以提供帮助,我将不胜感激!!!
版本信息:
-- Attaching packages --------------------------------------- tidyverse 1.3.0 --
v ggplot2 3.3.2 v purrr 0.3.4
v tibble 3.0.4 v dplyr 1.0.2
v tidyr 1.1.2 v stringr 1.4.0
v readr 1.4.0 v forcats 0.5.0
-- Conflicts ------------------------------------------ tidyverse_conflicts() --
x dplyr::filter() masks stats::filter()
x dplyr::lag() masks stats::lag()
-- Attaching packages -------------------------------------- tidymodels 0.1.1 --
v broom 0.7.2 v recipes 0.1.14
v dials 0.0.9 v rsample 0.0.8
v infer 0.5.3 v tune 0.1.1
v modeldata 0.0.2 v workflows 0.2.1
v parsnip 0.1.3.9000 v yardstick 0.0.7
-- Conflicts ----------------------------------------- tidymodels_conflicts() --
x scales::discard() masks purrr::discard()
x dplyr::filter() masks stats::filter()
x recipes::fixed() masks stringr::fixed()
x dplyr::lag() masks stats::lag()
x yardstick::spec() masks readr::spec()
x recipes::step() masks stats::step()
Windows 7
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 4
minor 0.3
year 2020
month 10
day 10
svn rev 79318
language R
version.string R version 4.0.3 (2020-10-10)
代码:
library(tidyverse)
library(tidymodels)
library(themis)
iris
# Data split
set.seed(999)
iris_split <- initial_split(iris, strata = Species)
iris_train <- training(iris_split)
iris_test <- testing(iris_split)
# Cross Validation
set.seed(345)
iris_fold <- vfold_cv(iris_train)
print(iris_fold)
# recipe
iris_rec <- recipe(Species ~., data = iris_train) %>%
#make sure the training set has equal numbers of target variale (not needed for iris dataset)
step_downsample(Species) %>%
#normalise the data
step_center(-Species) %>%
step_scale(-Species) %>%
step_BoxCox(-Species) %>%
#function to apply the recipe to the data
prep()
# Workflow
iris_wf <- workflow() %>%
add_recipe(iris_rec)
# logistic
glm_spec <- logistic_reg() %>%
set_engine("glm")
# to do parallel processing
doParallel::registerDoParallel()
# adding parameters to workflow
glm_rs <- iris_wf %>%
add_model(glm_spec) %>%
fit_resamples(
resamples = iris_fold,
metrics = metric_set(roc_auc, accuracy, sensitivity, specificity),
control = control_resamples(save_pred = TRUE)
)
错误
Warning message:
"All models failed in [fit_resamples()]. See the `.notes` column."
Warning message:
"This tuning result has notes. Example notes on model fitting include:
internal: Error: In metric: `roc_auc`
internal: Error: In metric: `roc_auc`
internal: Error: In metric: `roc_auc`"
# Resampling results
# 10-fold cross-validation
# A tibble: 10 x 5
splits id .metrics .notes .predictions
<list> <chr> <list> <list> <list>
1 <split [102/12]> Fold01 <NULL> <tibble [1 x 1]> <NULL>
2 <split [102/12]> Fold02 <NULL> <tibble [1 x 1]> <NULL>
3 <split [102/12]> Fold03 <NULL> <tibble [1 x 1]> <NULL>
4 <split [102/12]> Fold04 <NULL> <tibble [1 x 1]> <NULL>
5 <split [103/11]> Fold05 <NULL> <tibble [1 x 1]> <NULL>
6 <split [103/11]> Fold06 <NULL> <tibble [1 x 1]> <NULL>
7 <split [103/11]> Fold07 <NULL> <tibble [1 x 1]> <NULL>
8 <split [103/11]> Fold08 <NULL> <tibble [1 x 1]> <NULL>
9 <split [103/11]> Fold09 <NULL> <tibble [1 x 1]> <NULL>
10 <split [103/11]> Fold10 <NULL> <tibble [1 x 1]> <NULL>
(更新)
RF
即使不使用Parallel
计算也会出错
解决方案
我在 Linux 机器上遇到了同样的问题,但通过删除 NA 或它们的插补解决了这个问题。因此,似乎 NA 的存在导致模型拟合失败!:)
推荐阅读
- php - 将交互式 html 表单连接到 sql 数据库
- html - 寻找一种用三元赋值但没有其他条件的方法
- batch-file - 使用批处理在目录下查找大小为 0 的特定文件夹
- cloud - 为 OCI 上的通用 Windows Server 实例生成密码
- karate - Karate Gatling - How to run Gatling tests using Maven uber jar
- reactjs - issue while running test @types/testing-library__react/node_modules/pretty-format/build/index.d.ts (7, 13): '=' expected
- java - Oracle Database performance issue in spring-boot application
- c# - C# EF Core: How to map One-to-Zero with multiple properties (with Attributes only) [With Workaround]?
- android - BLE response back to Peripheral Connection mobile to mobile
- javascript - How do I use standalone Header in react-navigation with react-native?