Skip to content
Prev 294770 / 398502 Next

caret: Error when using rpart and CV != LOOCV

Thanks Max for your answer.

First, I do not understand your post. Why is it a problem if two of
predictions match? From the formula for calculating R^2 I can see that
there will be a DivByZero iff the total sum of squares is 0. This is
only true if the predictions of all the predicted points from the
test-set are equal to the mean of the test-set. Why should this happen?

Anyway, I wrote the following code to check what you tried to tell:

--
library(caret)
data(trees)
formula=Volume~Girth+Height

customSummary <- function (data, lev = NULL, model = NULL) {
    print(summary(data$pred))
    return(defaultSummary(data, lev, model))
}

tc=trainControl(method='cv', summaryFunction=customSummary)
train(formula, data=trees,  method='rpart', trControl=tc)
--

This outputs:
---
  Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  18.45   18.45   18.45   30.12   35.95   53.44
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  22.69   22.69   22.69   32.94   38.06   53.44
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  30.37   30.37   30.37   30.37   30.37   30.37
[cut many values like this]
Warning: In nominalTrainWorkflow(dat = trainData, info = trainInfo,
method = method,  :
  There were missing values in resampled performance measures.
-----

As I didn't understand your post, I don't know if this confirms your
assumption.

Thanks anyway,
Dominik
On 16/05/12 17:30, Max Kuhn wrote: