Metrics
Metric
dataclass
Bases: BaseMetric
Object Detection Metric.
Attributes:
Name | Type | Description |
---|---|---|
type |
str
|
The metric type. |
value |
int | float | dict
|
The metric value. |
parameters |
dict[str, Any]
|
A dictionary containing metric parameters. |
Source code in valor_lite/object_detection/metric.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 |
|
accuracy(value, iou_threshold, score_threshold)
classmethod
Accuracy metric for the object detection task type.
This class encapsulates a metric value at a specific Intersection over Union (IOU) threshold and confidence score threshold.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The metric value. |
required |
iou_threshold
|
float
|
The IOU threshold used to determine matches between predicted and ground truth boxes. |
required |
score_threshold
|
float
|
The confidence score threshold above which predictions are considered. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
average_precision(value, iou_threshold, label)
classmethod
Average Precision (AP) metric for object detection tasks.
The AP computation uses 101-point interpolation, which calculates the average precision by interpolating the precision-recall curve at 101 evenly spaced recall levels from 0 to 1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The average precision value. |
required |
iou_threshold
|
float
|
The IOU threshold used to compute the AP. |
required |
label
|
str
|
The class label for which the AP is computed. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
average_precision_averaged_over_IOUs(value, iou_thresholds, label)
classmethod
Average Precision (AP) metric averaged over multiple IOU thresholds.
The AP computation uses 101-point interpolation, which calculates the average precision
by interpolating the precision-recall curve at 101 evenly spaced recall levels from 0 to 1
for each IOU threshold specified in iou_thresholds
. The final APAveragedOverIOUs value is
obtained by averaging these AP values across all specified IOU thresholds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The average precision value averaged over the specified IOU thresholds. |
required |
iou_thresholds
|
list[float]
|
The list of IOU thresholds used to compute the AP values. |
required |
label
|
str
|
The class label for which the AP is computed. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
average_recall(value, score_threshold, iou_thresholds, label)
classmethod
Average Recall (AR) metric for object detection tasks.
The AR computation considers detections with confidence scores above the specified
score_threshold
and calculates the recall at each IOU threshold in iou_thresholds
.
The final AR value is the average of these recall values across all specified IOU
thresholds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The average recall value averaged over the specified IOU thresholds. |
required |
score_threshold
|
float
|
The detection score threshold; only detections with confidence scores above this threshold are considered. |
required |
iou_thresholds
|
list[float]
|
The list of IOU thresholds used to compute the recall values. |
required |
label
|
str
|
The class label for which the AR is computed. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
average_recall_averaged_over_scores(value, score_thresholds, iou_thresholds, label)
classmethod
Average Recall (AR) metric averaged over multiple score thresholds for a specific object class label.
The AR computation considers detections across multiple score_thresholds
and calculates
recall at each IOU threshold in iou_thresholds
. The final AR value is obtained by averaging
the recall values over all specified score thresholds and IOU thresholds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The average recall value averaged over the specified score thresholds and IOU thresholds. |
required |
score_thresholds
|
list[float]
|
The list of detection score thresholds; detections with confidence scores above each threshold are considered. |
required |
iou_thresholds
|
list[float]
|
The list of IOU thresholds used to compute the recall values. |
required |
label
|
str
|
The class label for which the AR is computed. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
confusion_matrix(confusion_matrix, unmatched_predictions, unmatched_ground_truths, score_threshold, iou_threshold, maximum_number_of_examples)
classmethod
Confusion matrix for object detection tasks.
This class encapsulates detailed information about the model's performance, including correct predictions, misclassifications, unmatched_predictions (subset of false positives), and unmatched ground truths (subset of false negatives). It provides counts and examples for each category to facilitate in-depth analysis.
Confusion Matrix Format:
{
Unmatched Predictions Format:
{
Unmatched Ground Truths Format:
{
Parameters:
Name | Type | Description | Default |
---|---|---|---|
confusion_matrix
|
dict
|
A nested dictionary where the first key is the ground truth label value, the second key
is the prediction label value, and the innermost dictionary contains either a |
required |
unmatched_predictions
|
dict
|
A dictionary where each key is a prediction label value with no corresponding ground truth
(subset of false positives). The value is a dictionary containing either a |
required |
unmatched_ground_truths
|
dict
|
A dictionary where each key is a ground truth label value for which the model failed to predict
(subset of false negatives). The value is a dictionary containing either a |
required |
score_threshold
|
float
|
The confidence score threshold used to filter predictions. |
required |
iou_threshold
|
float
|
The Intersection over Union (IOU) threshold used to determine true positives. |
required |
maximum_number_of_examples
|
int
|
The maximum number of examples per element. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 |
|
counts(tp, fp, fn, label, iou_threshold, score_threshold)
classmethod
Counts
encapsulates the counts of true positives (tp
), false positives (fp
),
and false negatives (fn
) for object detection evaluation, along with the associated
class label, Intersection over Union (IOU) threshold, and confidence score threshold.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tp
|
int
|
Number of true positives. |
required |
fp
|
int
|
Number of false positives. |
required |
fn
|
int
|
Number of false negatives. |
required |
label
|
str
|
The class label for which the counts are calculated. |
required |
iou_threshold
|
float
|
The IOU threshold used to determine a match between predicted and ground truth boxes. |
required |
score_threshold
|
float
|
The confidence score threshold above which predictions are considered. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
f1_score(value, label, iou_threshold, score_threshold)
classmethod
F1 score for a specific class label in object detection.
This class encapsulates a metric value for a particular class label, along with the associated Intersection over Union (IOU) threshold and confidence score threshold.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The metric value. |
required |
label
|
str
|
The class label for which the metric is calculated. |
required |
iou_threshold
|
float
|
The IOU threshold used to determine matches between predicted and ground truth boxes. |
required |
score_threshold
|
float
|
The confidence score threshold above which predictions are considered. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
mean_average_precision(value, iou_threshold)
classmethod
Mean Average Precision (mAP) metric for object detection tasks.
The AP computation uses 101-point interpolation, which calculates the average precision for each class by interpolating the precision-recall curve at 101 evenly spaced recall levels from 0 to 1. The mAP is then calculated by averaging these values across all class labels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The mean average precision value. |
required |
iou_threshold
|
float
|
The IOU threshold used to compute the mAP. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
mean_average_precision_averaged_over_IOUs(value, iou_thresholds)
classmethod
Mean Average Precision (mAP) metric averaged over multiple IOU thresholds.
The AP computation uses 101-point interpolation, which calculates the average precision
by interpolating the precision-recall curve at 101 evenly spaced recall levels from 0 to 1
for each IOU threshold specified in iou_thresholds
. The final mAPAveragedOverIOUs value is
obtained by averaging these AP values across all specified IOU thresholds and all class labels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The average precision value averaged over the specified IOU thresholds. |
required |
iou_thresholds
|
list[float]
|
The list of IOU thresholds used to compute the AP values. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
mean_average_recall(value, score_threshold, iou_thresholds)
classmethod
Mean Average Recall (mAR) metric for object detection tasks.
The mAR computation considers detections with confidence scores above the specified
score_threshold
and calculates recall at each IOU threshold in iou_thresholds
for
each label. The final mAR value is obtained by averaging these recall values over the
specified IOU thresholds and then averaging across all labels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The mean average recall value averaged over the specified IOU thresholds. |
required |
score_threshold
|
float
|
The detection score threshold; only detections with confidence scores above this threshold are considered. |
required |
iou_thresholds
|
list[float]
|
The list of IOU thresholds used to compute the recall values. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
mean_average_recall_averaged_over_scores(value, score_thresholds, iou_thresholds)
classmethod
Mean Average Recall (mAR) metric averaged over multiple score thresholds and IOU thresholds.
The mAR computation considers detections across multiple score_thresholds
, calculates recall
at each IOU threshold in iou_thresholds
for each label, averages these recall values over all
specified score thresholds and IOU thresholds, and then computes the mean across all labels to
obtain the final mAR value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The mean average recall value averaged over the specified score thresholds and IOU thresholds. |
required |
score_thresholds
|
list[float]
|
The list of detection score thresholds; detections with confidence scores above each threshold are considered. |
required |
iou_thresholds
|
list[float]
|
The list of IOU thresholds used to compute the recall values. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
precision(value, label, iou_threshold, score_threshold)
classmethod
Precision metric for a specific class label in object detection.
This class encapsulates a metric value for a particular class label, along with the associated Intersection over Union (IOU) threshold and confidence score threshold.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The metric value. |
required |
label
|
str
|
The class label for which the metric is calculated. |
required |
iou_threshold
|
float
|
The IOU threshold used to determine matches between predicted and ground truth boxes. |
required |
score_threshold
|
float
|
The confidence score threshold above which predictions are considered. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
precision_recall_curve(precisions, scores, iou_threshold, label)
classmethod
Interpolated precision-recall curve over 101 recall points.
The precision values are interpolated over recalls ranging from 0.0 to 1.0 in steps of 0.01, resulting in 101 points. This is a byproduct of the 101-point interpolation used in calculating the Average Precision (AP) metric in object detection tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
precisions
|
list[float]
|
Interpolated precision values corresponding to recalls at 0.0, 0.01, ..., 1.0. |
required |
scores
|
list[float]
|
Maximum prediction score for each point on the interpolated curve. |
required |
iou_threshold
|
float
|
The Intersection over Union (IOU) threshold used to determine true positives. |
required |
label
|
str
|
The class label associated with this precision-recall curve. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|
Source code in valor_lite/object_detection/metric.py
recall(value, label, iou_threshold, score_threshold)
classmethod
Recall metric for a specific class label in object detection.
This class encapsulates a metric value for a particular class label, along with the associated Intersection over Union (IOU) threshold and confidence score threshold.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The metric value. |
required |
label
|
str
|
The class label for which the metric is calculated. |
required |
iou_threshold
|
float
|
The IOU threshold used to determine matches between predicted and ground truth boxes. |
required |
score_threshold
|
float
|
The confidence score threshold above which predictions are considered. |
required |
Returns:
Type | Description |
---|---|
Metric
|
|