Ultralytics YOLO27:
License YOLO
Back to Ultralytics Glossary

Accuracy

Accuracy is the share of predictions a model gets right. Formula, top-1 and top-5 accuracy, the accuracy paradox on imbalanced data, and better metrics.

Accuracy is the fraction of a model's predictions that are correct: the number of correct predictions divided by the total number of predictions. It is the default score for image classification and other supervised learning tasks with one label per input, and it answers the plainest question about a model, how often it is right. Accuracy is easy to read and compare across models, but it weighs every prediction equally, so on imbalanced data a model can score high while failing on exactly the cases that matter.

How Accuracy Is Calculated#

For a binary task, the four counts of a confusion matrix give accuracy = (TP + TN) / (TP + TN + FP + FN): true positives plus true negatives over all predictions. For a task with many classes, accuracy is the sum of the matrix diagonal over the total count, and scikit-learn's accuracy_score computes it directly from two arrays of labels. Accuracy is often reported as an error rate instead, where error = 1 − accuracy.

Top-1 and Top-5 Accuracy#

Classifiers with many classes also report top-k accuracy. Top-1 accuracy counts a prediction as correct only when the highest-scoring class is the true label, and top-5 accuracy counts it as correct when the true label is anywhere among the five highest-scoring classes. Top-5 became standard with the ImageNet challenge, whose photos often contain several objects but carry a single label from 1,000 classes. YOLO26 classification models report both numbers, and the nano model, yolo26n-cls.pt, reaches 71.4% top-1 and 90.1% top-5 accuracy on ImageNet at 224 pixels.

  • Precision: of the predicted positives, the share that are truly positive. It rises as false alarms fall.
  • Recall: of the actual positives, the share the model finds. It is the number that exposes a model that ignores a rare class.
  • F1-score: the harmonic mean of precision and recall, which stays low unless both are high.
  • Mean average precision (mAP): the standard metric for object detection, where accuracy does not apply because the background offers no countable true negatives, only an unlimited number of empty image regions.

The Accuracy Paradox#

When one class dominates, accuracy rewards ignoring the rare class. If 1% of transactions are fraudulent, a model that approves every transaction is 99% accurate and catches no fraud at all, a pattern known as the accuracy paradox. The same trap appears in defect inspection, disease screening, and anomaly detection, where the class of interest is rare by nature.

import numpy as np
from sklearn.metrics import accuracy_score, balanced_accuracy_score, recall_score

# 1,000 transactions, 10 of them fraudulent (label 1)
y_true = np.zeros(1000, dtype=int)
y_true[:10] = 1

# A model that labels every transaction as legitimate
y_pred = np.zeros(1000, dtype=int)

print(f"Accuracy: {accuracy_score(y_true, y_pred):.2f}")
print(f"Balanced accuracy: {balanced_accuracy_score(y_true, y_pred):.2f}")
print(f"Fraud recall: {recall_score(y_true, y_pred):.2f}")

Balanced accuracy, the mean recall across classes, exposes the failure that plain accuracy hides: the script prints an accuracy of 0.99, a balanced accuracy of 0.50, and a fraud recall of 0.00.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Transform drone and aerial imagery into real-time insights for agriculture, aquaculture, environmental monitoring, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Bring vision AI to aerial monitoring with Ultralytics YOLO models. Power drones, aerospace workflows, environmental conservation & geospatial industries with computer vision solutions.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more
Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Transform drone and aerial imagery into real-time insights for agriculture, aquaculture, environmental monitoring, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Bring vision AI to aerial monitoring with Ultralytics YOLO models. Power drones, aerospace workflows, environmental conservation & geospatial industries with computer vision solutions.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more
Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Transform drone and aerial imagery into real-time insights for agriculture, aquaculture, environmental monitoring, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Bring vision AI to aerial monitoring with Ultralytics YOLO models. Power drones, aerospace workflows, environmental conservation & geospatial industries with computer vision solutions.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning