Cross-validation for Classification and Regression Trees
cv.crtree( object, K = 5, repeats = 1, cp, pcp = seq(0, 0.01, length.out = 11), seed = 1234, trace = TRUE, fun, ... )
object | Object of type "rpart" or "crtree" to use as a starting point for cross validation |
---|---|
K | Number of cross validation passes to use |
repeats | Number of times to repeat the K cross-validation steps |
cp | Complexity parameter used when building the (e.g., 0.0001) |
pcp | Complexity parameter to use for pruning |
seed | Random seed to use as the starting point |
trace | Print progress |
fun | Function to use for model evaluation (e.g., auc for classification or RMSE for regression) |
... | Additional arguments to be passed to 'fun' |
A data.frame sorted by the mean, sd, min, and max of the performance metric
See https://radiant-rstats.github.io/docs/model/crtree.html for an example in Radiant
crtree
to generate an initial model that can be passed to cv.crtree
Rsq
to calculate an R-squared measure for a regression
RMSE
to calculate the Root Mean Squared Error for a regression
MAE
to calculate the Mean Absolute Error for a regression
auc
to calculate the area under the ROC curve for classification
profit
to calculate profits for classification at a cost/margin threshold
if (FALSE) { result <- crtree(dvd, "buy", c("coupon", "purch", "last")) cv.crtree(result, cp = 0.0001, pcp = seq(0, 0.01, length.out = 11)) cv.crtree(result, cp = 0.0001, pcp = c(0, 0.001, 0.002), fun = profit, cost = 1, margin = 5) result <- crtree(diamonds, "price", c("carat", "color", "clarity"), type = "regression", cp = 0.001) cv.crtree(result, cp = 0.001, pcp = seq(0, 0.01, length.out = 11), fun = MAE) }