{
  "name": "accuracy_score return values by argument setting (scikit-learn 1.9.1)",
  "description": "Return value of sklearn.metrics.accuracy_score for different argument settings and input types, compiled by running each call under scikit-learn 1.9.1 and checking the behaviour against the official API reference and user guide.",
  "page": "https://casrai.org/guides/sklearn-accuracy-score",
  "publisher": "CASRAI",
  "license": "https://creativecommons.org/licenses/by/4.0/",
  "dateModified": "2026-11-16T21:57:12Z",
  "temporalCoverage": "scikit-learn 1.9.1",
  "spatialCoverage": null,
  "columns": [
    {
      "name": "Call",
      "unit": "",
      "description": ""
    },
    {
      "name": "Input",
      "unit": "",
      "description": "Labels used"
    },
    {
      "name": "Result",
      "unit": "",
      "description": "Value returned or error raised"
    },
    {
      "name": "Documented behaviour",
      "unit": "",
      "description": ""
    }
  ],
  "rows": [
    {
      "Call": "accuracy_score(y_true, y_pred)",
      "Input": "y_true=[0,1,2,3], y_pred=[0,2,1,3]",
      "Result": 0.5,
      "Documented behaviour": "Fraction of correctly classified samples (normalize=True)"
    },
    {
      "Call": "accuracy_score(y_true, y_pred, normalize=False)",
      "Input": "y_true=[0,1,2,3], y_pred=[0,2,1,3]",
      "Result": 2,
      "Documented behaviour": "Number of correctly classified samples"
    },
    {
      "Call": "accuracy_score(y_true, y_pred, sample_weight=[1,1,1,3])",
      "Input": "y_true=[0,1,2,3], y_pred=[0,2,1,3]",
      "Result": 0.6667,
      "Documented behaviour": "Weighted fraction: (1+3)/6"
    },
    {
      "Call": "accuracy_score(y_true, y_pred)",
      "Input": "Multilabel: [[0,1],[1,1]] vs all ones",
      "Result": 0.5,
      "Documented behaviour": "Subset accuracy: label set must match exactly"
    },
    {
      "Call": "accuracy_score(y_true, y_pred)",
      "Input": "String labels: cat,dog,dog vs cat,dog,cat",
      "Result": 0.6667,
      "Documented behaviour": "Labels need not be numeric"
    },
    {
      "Call": "accuracy_score(y_true, y_pred)",
      "Input": "90 class 0 and 10 class 1, all predicted 0",
      "Result": 0.9,
      "Documented behaviour": "Accuracy counts every sample equally"
    },
    {
      "Call": "balanced_accuracy_score(y_true, y_pred)",
      "Input": "Same imbalanced set, all predicted 0",
      "Result": 0.5,
      "Documented behaviour": "Macro-average of per-class recall"
    },
    {
      "Call": "accuracy_score(y_true, y_pred)",
      "Input": "Lengths 3 and 2",
      "Result": "ValueError: inconsistent numbers of samples",
      "Documented behaviour": "Both arrays must be the same length"
    },
    {
      "Call": "accuracy_score(y_true, y_pred)",
      "Input": "Continuous y_true [0.5,1.2], y_pred [0,1]",
      "Result": "ValueError: mix of continuous and binary targets",
      "Documented behaviour": "Classification metric; labels required"
    }
  ],
  "sources": [
    {
      "title": "sklearn.metrics.accuracy_score (scikit-learn 1.9.1)",
      "url": "https://scikit-learn.org/stable/modules/generated/sklearn.metrics.accuracy_score.html",
      "accessed": "2026-11-15"
    },
    {
      "title": "Metrics and scoring: quantifying the quality of predictions",
      "url": "https://scikit-learn.org/stable/modules/model_evaluation.html",
      "accessed": "2026-11-15"
    }
  ]
}