Error: some required components are missing: prob?
Error: some required components are missing: prob?
我按照这个指南创建了自己的插入符号模型 Creating Your Own Model。那里说
If a regression model is being used or if the classification model
does not create class probabilities a value of NULL can be used here
instead of a function
所以我这样做了
# Define the model cFBasic
cFBasic <- list(type = "Regression",
library = c("lubridate", "stringr"),
loop = NULL)
...
cFBasic$prob <- NULL
cFBasic$sort <- NULL
但是,当我尝试测试模型时,出现以下错误:
control <- trainControl(method = "cv",
number = 10,
p = .9,
allowParallel = TRUE)
fit <- train(x = calib_set,
y = calib_set$y,
method = cFBasic,
trControl = control)
Error: some required components are missing: prob
我该如何解决?除了添加函数 prob 来生成伪造的 pro
数据框以使 caret
快乐。
通过键入 cFBasic$prob <- NULL
,您实际上并没有向列表中添加新项目。
看看这个:
cFBasic <- list(prob = NULL)
cFBasic
#> $prob
#> NULL
cFBasic$prob <- NULL
cFBasic
#> named list()
当您将 NULL 分配给列表的对象时,您将删除该对象。如果您想将一个名为 prob
的 NULL 对象和一个名为 sort
的 NULL 对象添加到列表中,您应该这样输入:
# Define the model cFBasic
cFBasic <- list(type = "Regression",
library = c("lubridate", "stringr"),
loop = NULL)
...
cFBasic <- c(cFBasic, list(prob = NULL))
cFBasic <- c(cFBasic, list(sort = NULL))
试一试。
我按照这个指南创建了自己的插入符号模型 Creating Your Own Model。那里说
If a regression model is being used or if the classification model does not create class probabilities a value of NULL can be used here instead of a function
所以我这样做了
# Define the model cFBasic
cFBasic <- list(type = "Regression",
library = c("lubridate", "stringr"),
loop = NULL)
...
cFBasic$prob <- NULL
cFBasic$sort <- NULL
但是,当我尝试测试模型时,出现以下错误:
control <- trainControl(method = "cv",
number = 10,
p = .9,
allowParallel = TRUE)
fit <- train(x = calib_set,
y = calib_set$y,
method = cFBasic,
trControl = control)
Error: some required components are missing: prob
我该如何解决?除了添加函数 prob 来生成伪造的 pro
数据框以使 caret
快乐。
通过键入 cFBasic$prob <- NULL
,您实际上并没有向列表中添加新项目。
看看这个:
cFBasic <- list(prob = NULL)
cFBasic
#> $prob
#> NULL
cFBasic$prob <- NULL
cFBasic
#> named list()
当您将 NULL 分配给列表的对象时,您将删除该对象。如果您想将一个名为 prob
的 NULL 对象和一个名为 sort
的 NULL 对象添加到列表中,您应该这样输入:
# Define the model cFBasic
cFBasic <- list(type = "Regression",
library = c("lubridate", "stringr"),
loop = NULL)
...
cFBasic <- c(cFBasic, list(prob = NULL))
cFBasic <- c(cFBasic, list(sort = NULL))
试一试。