2015-10-17 30 views
0

在我的數據集上使用以下內容時,出現錯誤消息。rpart在嘗試創建分類樹時未運行

rpmodel <- train(Class~.,train, method = "rpart", prox = TRUE) 


Something is wrong; all the Accuracy metric values are missing: 
    Accuracy  Kappa  
Min. : NA Min. : NA 
1st Qu.: NA 1st Qu.: NA 
Median : NA Median : NA 
Mean :NaN Mean :NaN 
3rd Qu.: NA 3rd Qu.: NA 
Max. : NA Max. : NA 
NA's :3  NA's :3  
Error in train.default(x, y, weights = w, ...) : Stopping 
In addition: There were 26 warnings (use warnings() to see them) 

但是在數據集中沒有NA

+0

說什麼警告? –

+0

@XavierNayrac我發佈了正在顯示的警告 – amankedia

+0

請發佈警告。你將通過輸入'warnings()'來看到它們。 –

回答

0

您可能過濾了一個或多個因子變量。嘗試重構它們,因爲因素級別​​仍然可用。另請參閱github上的this issue

sapply(train, class) 
# refactor all variables with class factor 
variable <- factor(as.character(variable) 
+0

看到他們謝謝我會嘗試一下@phiver – amankedia

1

警告告訴你這個問題。你是傳遞一個參數(prox)既不是參數trainrpart

> "prox" %in% names(formals(rpart)) 
[1] FALSE 
> "prox" %in% names(formals(train.formula)) 
[1] FALSE 

最大