postResample(pred, obs) defaultSummary(data, lev = NULL, model = NULL)
predfor hte observed and predicted outcomes
postResampleis meant to be used with
applyacross a matrix. For numeric data the code checks to see if the standard deviation of either vector is zero. If so, the correlation between those samples is assigned a value of zero.
NAvalues are ignored everywhere.
Note that many models have more predictors (or parameters) than data points, so the typical mean squared
error denominator (n - p) does not apply. Root mean squared error is calculated using
sqrt(mean((pred - obs)^2.
Also, R-squared is calculated as the square of the correlation between the observed and predicted outcomes.
defaultSummary is the default function to compute performance metrics in
train. It is a wrapper around
Other functions can be used via the
summaryFunction argument of
trainControl. Custom functions must have the same arguments as
predicted <- matrix(rnorm(50), ncol = 5) observed <- rnorm(10) apply(predicted, 2, postResample, obs = observed)