Skip to contents

Calculates the accuracy of the model by taking the mean of the number of times the truth, \(y\), equals the predicted, \(\hat{y}\).

Usage

acc(y, yhat)

Arguments

y

A vector of the true \(y\) values

yhat

A vector of predicted \(\hat{y}\) values.

Value

The accuracy of the classification in numeric form.

Examples

# Set seed for reproducibility
set.seed(100)

# Generate data
n = 1e2

y = round(runif(n))
yhat = round(runif(n))

# Compute
o = acc(y, yhat)