![](/img/trans.png)
[英]Error in train.default(x, y, weights = w, …) : final tuning parameters could not be determined
[英]Caret "Error in train.default(x, y, weights = w, ...) : final tuning parameters could not be determined" when optimizing for ROC
我正在嘗試創建一個二元分類器,用caret
建模以優化 ROC。 我嘗試的方法是C5.0
,我收到以下錯誤和警告:
Error in train.default(x, y, weights = w, ...) :
final tuning parameters could not be determined
In addition: Warning messages:
1: In nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
There were missing values in resampled performance measures.
2: In train.default(x, y, weights = w, ...) :
missing values found in aggregated results
我之前使用C5.0
和caret
對相同的訓練數據進行了建模,但針對准確度進行了優化,並且沒有在控件中使用 twoClassSummary,並且它運行時沒有錯誤。
我對 ROC 運行的調整網格和控制是
c50Grid <- expand.grid(.trials = c(1:9, (1:10)*10),
.model = c("tree", "rules"),
.winnow = c(TRUE, FALSE))
fitTwoClass <- trainControl(
method = "repeatedcv",
number = 5,
repeats = 5,
classProbs=TRUE,
summaryFunction = twoClassSummary
)
在 Accuracy 運行期間,我省略了控件的classProbs
和summaryFunction
部分。
對於建模,命令是
fitModel <- train(
Unhappiness ~ .,
data = dnumTrain,
tuneGrid=c50Grid,
method = "C5.0",
trControl = fitTwoClass,
tuneLength = 5,
metric= "ROC"
)
誰能建議如何解決這個問題? 不確定要調整什么參數才能使這項工作正常工作,而我相信數據集應該沒問題(因為它在優化精度時運行正常)。
要重現,可以從此鏈接中的文件load
訓練集dnumTrain
。
我想我可能已經解決了這個問題:在評論中看到@Pascal 能夠毫無錯誤地運行代碼,並意識到我用ctree
運行它時得到了一個非常隨機的結果,我調查了可能與隨機性有關的其他領域: 隨機種子。
似乎問題來自我使用doSNOW
將過程並行doSNOW
到 4 個處理器,並且需要為每次迭代設置種子以避免隨機性蔓延(請參閱此問題的答案)。 我懷疑隨機數據會導致某些折疊沒有有效值。
無論如何,我將種子設置如下:
CVfolds <- 5
CVreps <- 5
seedNum <- CVfolds * CVreps + 1
seedLen <- CVfolds + tuneLength
# create manual seeds vector for parallel processing repeatibility
set.seed(123)
seeds <- vector(mode = "list", length = seedNum)
for(i in 1:(seedNum-1)) seeds[[i]] <- sample.int(1000, seedLen)
## For the last model:
seeds[[seedNum]] <- sample.int(1000, 1)
fitTwoClass <- trainControl(
method = "repeatedcv",
number = CVfolds,
repeats = CVreps,
classProbs=TRUE,
summaryFunction = twoClassSummary,
seeds = seeds
)
到目前為止,我已經重新訓練了fitModel
3 次並且還沒有錯誤/警告,所以我希望這確實是我問題的答案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.