Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/alexplatasl/dplbnde/llms.txt

Use this file to discover all available pages before exploring further.

accuracy computes the fraction of correctly classified observations.

Usage

accuracy(x, y)

Parameters

x
character or factor
required
Vector of predicted class labels.
y
character or factor
required
Vector of true class labels. Must be the same length as x.

Return value

A numeric scalar in [0, 1]: the proportion of predictions that match the true labels.

Errors

  • Throws an error if x and y have different lengths
  • Throws an error if either argument is not a character or factor vector

Examples

library(dplbnDE)
data(car)

result <- lshade(
  NP = 15, G = 15,
  data = car,
  class.name = names(car)[7],
  structure = "tan",
  verbose = 0
)

predictions <- predict(result$Best, car)
acc <- accuracy(predictions, car$class)
cat("Accuracy:", round(acc * 100, 2), "%\n")
accuracy() evaluates on the training data when you pass the same data used for learning. For a more realistic estimate, split your data into train and test sets before running the algorithm.

Build docs developers (and LLMs) love