accuracy: Accuracy measures

View source: R/accuracy.R

accuracyR Documentation

Accuracy measures

Description

Computes accuracy measurements.

Usage

accuracy(pred, obs, na.rm = FALSE, tol = sqrt(.Machine$double.eps))

Arguments

pred

a numeric vector with the predicted values.

obs

a numeric vector with the observed values.

na.rm

a logical indicating whether NA values should be stripped before the computation proceeds.

tol

divide underflow tolerance.

Value

Returns a named vector with the following components:

  • me mean error

  • rmse root mean squared error

  • mae mean absolute error

  • mpe mean percent error

  • mape mean absolute percent error

  • r.squared pseudo R-squared

See Also

pred.plot()

Examples

set.seed(1)
nobs <- nrow(bodyfat)
itrain <- sample(nobs, 0.8 * nobs)
train <- bodyfat[itrain, ]
test <- bodyfat[-itrain, ]
fit <- lm(bodyfat ~ abdomen + wrist, data = train)
pred <- predict(fit, newdata = test)
obs <- test$bodyfat
pred.plot(pred, obs)
accuracy(pred, obs)

mpae documentation built on May 29, 2024, 5:25 a.m.