{
  "id": "classification-accuracy",
  "title": "Classification Accuracy",
  "lang": "en",
  "source_lang": "en",
  "summary": "Classification accuracy is the proportion of evaluated examples for which a classifier predicts the correct class label.",
  "category": "mathematics",
  "subcategory": "probability-statistics",
  "type": "concept",
  "aliases": [
    "Accuracy score",
    "Classification success rate",
    "Proportion correctly classified"
  ],
  "generated_at": "2026-11-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/classification-accuracy/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/classification-accuracy/",
      "json": "https://aiwiki.page/zh/classification-accuracy.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "Classification accuracy is the proportion of examples for which a classifier’s predicted label matches the reference label. It is a widely used measure in machine learning and statistics for evaluating classification systems. In its standard form, accuracy gives every evaluated example equal weight and treats every incorrect prediction as equally wrong. Its simplicity makes it easy to interpret, but it can conceal poor performance on rare classes, unequal error costs, and differences between evaluation data and the population in which a system operates."
    },
    {
      "heading": "Definition",
      "text": "For a dataset of \\(n>0\\) examples, let \\(y_i\\) be the reference label of example \\(i\\), and let \\(\\hat y_i\\) be its predicted label. Classification accuracy is\n\n\\[\\widehat{\\operatorname{Acc}} = \\frac{1}{n} \\sum_{i=1}^{n} \\mathbf{1}\\{\\hat y_i=y_i\\},\\]\n\nwhere \\(\\mathbf{1}\\{\\cdot\\}\\) is the indicator function, equal to 1 when its condition is true and 0 otherwise.\n\nAccuracy lies between 0 and 1 and is often expressed as a percentage. A classifier that correctly labels 87 of 100 examples has an accuracy of \\(0.87\\), or \\(87\\%\\). The corresponding classification error rate is\n\n\\[\\widehat{\\operatorname{Err}} = 1-\\widehat{\\operatorname{Acc}}.\\]\n\nThis definition applies directly to binary and multiclass tasks in which each example has exactly one reference label and receives exactly one predicted label. Tasks allowing several labels per example require an explicit definition of what counts as a correct prediction.\n\nPopulation accuracy\n\nFor a fixed classifier \\(f\\), population accuracy is the probability of a correct prediction on a randomly drawn input–label pair \\((X,Y)\\):\n\n\\[\\operatorname{Acc}(f) = \\Pr\\{f(X)=Y\\}.\\]\n\nAn observed test accuracy estimates this quantity for the population represented by the test data. Accuracy is therefore not solely a property of a model: it also depends on the data distribution, the reference labels, and the rule used to convert model outputs into predictions."
    },
    {
      "heading": "Confusion-matrix formulation",
      "text": "For binary classification, predictions can be summarized in a confusion matrix:\n\nReference label | Predicted positive | Predicted negative\nPositive | True positives (\\(TP\\)) | False negatives (\\(FN\\))\nNegative | False positives (\\(FP\\)) | True negatives (\\(TN\\))\n\nAccuracy is\n\n\\[\\operatorname{Acc} = \\frac{TP+TN}{TP+TN+FP+FN}.\\]\n\nUnlike precision and recall, accuracy includes both correctly identified positive examples and correctly identified negative examples. It does not distinguish false positives from false negatives when counting errors.\n\nFor a multiclass confusion matrix \\(C\\), with reference classes represented by rows and predicted classes by columns,\n\n\\[\\operatorname{Acc} = \\frac{\\sum_{k=1}^{K}C_{kk}} {\\sum_{j=1}^{K}\\sum_{k=1}^{K}C_{jk}}.\\]\n\nThus, accuracy is the sum of the diagonal entries divided by the total number of evaluated examples."
    },
    {
      "heading": "Statistical interpretation and uncertainty",
      "text": "Each prediction can be represented by a correctness variable,\n\n\\[Z_i=\\mathbf{1}\\{\\hat y_i=y_i\\}.\\]\n\nAccuracy is then the sample mean of these variables. If a fixed classifier is evaluated on independent examples drawn from the same distribution, each \\(Z_i\\) has a Bernoulli distribution with success probability \\(p=\\operatorname{Acc}(f)\\). The number of correct predictions follows a binomial distribution:\n\n\\[n\\widehat{\\operatorname{Acc}} \\sim \\operatorname{Binomial}(n,p).\\]\n\nUnder these assumptions,\n\n\\[\\mathbb{E}[\\widehat{\\operatorname{Acc}}]=p, \\qquad \\operatorname{Var}(\\widehat{\\operatorname{Acc}}) = \\frac{p(1-p)}{n}.\\]\n\nA common estimated standard error is\n\n\\[\\widehat{\\operatorname{SE}} = \\sqrt{ \\frac{ \\widehat{\\operatorname{Acc}} (1-\\widehat{\\operatorname{Acc}}) }{n} }.\\]\n\nA confidence interval expresses sampling uncertainty around the estimate. Normal-approximation intervals can perform poorly with small samples or accuracy close to 0 or 1; Wilson or exact binomial intervals are alternatives.\n\nThese formulas do not automatically apply to dependent observations, such as repeated measurements from the same person or adjacent frames from a video. They also do not account for uncertainty caused by training a model on a different dataset. Test-set sampling uncertainty and variation across training runs are distinct sources of variability."
    },
    {
      "heading": "Evaluation design",
      "text": "Training and test accuracy\n\nTraining accuracy is measured on the training data used to fit a model. Test accuracy is measured on held-out examples not used to fit or select it.\n\nTraining accuracy can be substantially higher than accuracy on new data, particularly for flexible models. A high training score alone therefore does not establish good generalization.\n\nA test set also ceases to provide a clean final evaluation if its results repeatedly influence model selection, feature selection, or other design decisions. Information from the test set has then entered the development process.\n\nCross-validation estimates performance by repeatedly separating data into fitting and evaluation subsets. When it is also used to tune a model, a separate test set or nested evaluation distinguishes selection from final assessment. An unweighted mean of fold accuracies equals the pooled proportion correct only when fold sizes are equal; otherwise, pooling corresponds to a size-weighted mean.\n\nComparing classifiers\n\nAccuracy differences are interpretable only in relation to a shared task and evaluation protocol. Relevant conditions include class definitions, test-population composition, label quality, and preprocessing.\n\nWhen two classifiers are tested on the same examples, their results are paired. The uncertainty in their accuracy difference depends on which examples they disagree on, not merely on the two accuracy values considered separately. Appropriate statistical tests and paired resampling procedures can account for this structure."
    },
    {
      "heading": "Class imbalance and baseline performance",
      "text": "Accuracy weights classes according to their prevalence in the evaluation population. For classes \\(1,\\ldots,K\\),\n\n\\[\\operatorname{Acc} = \\sum_{k=1}^{K} \\Pr(Y=k)\\, \\Pr(\\hat Y=k\\mid Y=k).\\]\n\nIt is therefore a prevalence-weighted average of class-specific recall.\n\nSuppose 990 of 1,000 examples are negative and 10 are positive. A classifier that always predicts negative achieves \\(99\\%\\) accuracy while identifying none of the positive examples. This score correctly describes its overall proportion correct, but not its usefulness for detecting positives.\n\nA common baseline is the majority-class classifier, which always predicts the most frequent class. Its accuracy is the prevalence of that class. Chance accuracy is not necessarily \\(50\\%\\) for binary tasks or \\(1/K\\) for \\(K\\)-class tasks; it depends on the guessing rule. For example, if predictions are independent of the true labels and use class probabilities \\(q_k\\), expected accuracy is\n\n\\[\\sum_{k=1}^{K}p_kq_k,\\]\n\nwhere \\(p_k\\) is the true prevalence of class \\(k\\).\n\nBalanced accuracy gives equal weight to class-specific recalls:\n\n\\[\\operatorname{BalancedAcc} = \\frac{1}{K} \\sum_{k=1}^{K} \\Pr(\\hat Y=k\\mid Y=k).\\]\n\nFor binary classification, this is the average of sensitivity and specificity. It addresses unequal class weighting, but it still does not encode application-specific error costs."
    },
    {
      "heading": "Decision rules and optimization",
      "text": "Many classifiers output scores or probabilities rather than labels. Accuracy is calculated only after a decision rule converts those outputs into labels.\n\nFor a binary classifier with score \\(s(x)\\), a threshold rule may be written as\n\n\\[\\hat y= \\begin{cases} 1,&s(x)\\ge t,\\\\ 0,&s(x)<t. \\end{cases}\\]\n\nChanging \\(t\\) changes the confusion matrix and generally changes accuracy. If \\(s(x)\\) is the true conditional probability \\(\\Pr(Y=1\\mid X=x)\\), choosing the more probable class maximizes population accuracy. For multiclass classification, the corresponding rule is\n\n\\[f^*(x) \\in \\operatorname*{arg\\,max}_{k} \\Pr(Y=k\\mid X=x).\\]\n\nThis is the Bayes-optimal rule under equal costs for all incorrect predictions. It does not imply perfect accuracy: uncertainty in the labels given the input can leave an irreducible error.\n\nAccuracy corresponds to one minus the average zero–one loss,\n\n\\[\\ell(y,\\hat y)=\\mathbf{1}\\{y\\ne\\hat y\\}.\\]\n\nThis loss function is discontinuous as a function of many model parameters and is generally unsuitable for direct gradient-based training. Models are therefore often trained using surrogate objectives such as cross-entropy, while accuracy is reported for evaluation.\n\nIf different errors have different consequences, maximizing accuracy need not minimize expected cost. Decision theory instead evaluates actions using the probabilities and costs of their possible outcomes."
    },
    {
      "heading": "Variants and related measures",
      "text": "Weighted accuracy\n\nFor nonnegative example weights \\(w_i\\) with positive total weight,\n\n\\[\\operatorname{Acc}_w = \\frac{\\sum_i w_i\\mathbf{1}\\{\\hat y_i=y_i\\}} {\\sum_i w_i}.\\]\n\nWeights may represent sampling adjustments or a deliberately chosen emphasis on certain examples. Weighted and unweighted accuracy answer different questions, so the weighting scheme is part of the metric’s definition.\n\nTop-\\(k\\) accuracy\n\nTop-\\(k\\) accuracy counts an example as correct when its reference class appears among the model’s \\(k\\) highest-ranked predictions. Top-1 accuracy is ordinary accuracy when the highest-ranked class determines the prediction.\n\nFor a fixed ranking, top-\\(k\\) accuracy cannot decrease as \\(k\\) increases. Scores using different values of \\(k\\) are therefore not directly interchangeable.\n\nMultilabel accuracy\n\nIn multilabel classification, each example can have several correct labels. Exact-match accuracy, also called subset accuracy, counts an example as correct only when its entire predicted label set matches the reference set:\n\n\\[\\operatorname{ExactMatch} = \\frac{1}{n} \\sum_{i=1}^{n} \\mathbf{1}\\{\\hat Y_i=Y_i\\}.\\]\n\nA label-wise proportion correct instead counts individual label decisions. These measures can differ substantially: a prediction with one incorrect label fails exact match even if all its other labels are correct.\n\nOther performance measures\n\nPrecision, recall, and the F-score emphasize different aspects of class-specific performance. Probability-based losses assess information that accuracy discards: two classifiers can make exactly the same label predictions, and hence have identical accuracy, while assigning very different probabilities.\n\nAccuracy also does not measure probability calibration—the agreement between predicted probabilities and observed frequencies—or the quality of a ranking across decision thresholds."
    },
    {
      "heading": "Interpretation limits",
      "text": "Accuracy depends on the correctness and consistency of reference labels. Ambiguous class definitions, annotation errors, and changes in labeling policy can affect the score independently of the classifier’s underlying capabilities.\n\nA change in class prevalence can change accuracy even if recall within each class stays constant. Changes in inputs or in the relationship between inputs and labels can also make a historical test score unrepresentative of later performance.\n\nAn aggregate score can conceal differences across subgroups, environments, or types of example. Likewise, a large test set does not eliminate selection bias: a precise estimate for an unrepresentative sample can still misdescribe the intended population.\n\nInterpretable reporting therefore includes the evaluation sample size, class composition, prediction rule, and uncertainty, together with class-specific or cost-sensitive measures when those distinctions matter."
    }
  ],
  "links": [
    "machine-learning",
    "statistics",
    "indicator-function",
    "probability",
    "confusion-matrix",
    "precision-and-recall",
    "sample-mean",
    "bernoulli-distribution",
    "binomial-distribution",
    "standard-error",
    "confidence-interval",
    "training-data",
    "cross-validation",
    "statistical-hypothesis-testing",
    "conditional-probability",
    "loss-function",
    "cross-entropy",
    "decision-theory",
    "f-score",
    "selection-bias"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}