accuracy | R Documentation |
Computes accuracy measurements.
accuracy(pred, obs, na.rm = FALSE, tol = sqrt(.Machine$double.eps))
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. |
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
pred.plot()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.