plot_training_convergence
Plot training convergence: up to three subplots (mean_by_class, mean_by_feature_class, correlation).
Data source: exactly one of trainer, model_path, or training_stats.
- trainer: uses trainer.get_training_stats() (or in-memory stats if available).
- model_path: uses load_training_stats(model_path).
- training_stats: dict with keys training_stats, best_score_checkpoint (or raw training_stats dict).
Three plot options, each in its own subplot when enabled:
- plot_mean_by_class: mean encoded value per label over steps.
- plot_mean_by_feature_class: mean encoded value per feature class over steps.
- plot_correlation: correlation over steps. Best checkpoint step is marked in each subplot.
- class_spread: shade encoded value spread per class behind each mean line
("minmax" = min-max, "iqr" = Q1-Q3, "ci95" = 95% confidence interval).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trainer
|
Any
|
Trainer instance with get_training_stats(model_path) or similar. |
None
|
model_path
|
Optional[str]
|
Path to saved model dir (training.json). |
None
|
training_stats
|
Optional[Dict[str, Any]]
|
Pre-loaded run info or raw training_stats dict. |
None
|
plot_mean_by_class
|
bool
|
Add a subplot for mean_by_class. |
True
|
plot_mean_by_feature_class
|
Optional[bool]
|
Add a subplot for mean_by_feature_class. None = auto (False when redundant with mean_by_class, True otherwise). |
None
|
plot_correlation
|
bool
|
Add a subplot for correlation. |
True
|
class_spread
|
ClassSpreadMode
|
Shade spread per class (and feature class) behind mean lines.
|
None
|
best_step
|
bool
|
Mark the best checkpoint step (vertical line + point on correlation). |
True
|
label_name_mapping
|
Optional[Dict[str, str]]
|
Optional display names for label values. |
None
|
output
|
Optional[str]
|
Explicit output path for the plot file. |
None
|
experiment_dir
|
Optional[str]
|
Used with resolve_output_path for default artifact path. |
None
|
show
|
bool
|
Whether to call plt.show(). |
True
|
title
|
Union[str, bool]
|
True (default run_id), False, or custom string. |
True
|
figsize
|
Optional[Tuple[float, float]]
|
(width, height) for figure. |
None
|
img_format
|
str
|
File extension used when resolving the default output path. |
'png'
|
dpi
|
Optional[int]
|
Optional Matplotlib savefig DPI. |
None
|
legend_ncol
|
Optional[int]
|
Number of columns for the external legend when there are >= 6 series (default 1). |
None
|
legend_bbox_to_anchor
|
Optional[Tuple[float, float]]
|
(x, y) for the external legend when >= 6 series (default (1.02, 0.5)). |
None
|
legend_loc
|
Optional[str]
|
Matplotlib loc for the external legend when >= 6 series (default "center left"). |
None
|
highlight_non_convergence
|
Optional[bool]
|
When True, append a non-convergence marker to the title for
non-converged runs. |
None
|
return_fig_ax
|
bool
|
If True, return |
False
|
**kwargs
|
Any
|
Reserved for compatibility with trainer visualizer wrappers. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
Path to saved plot file, or "" if nothing to plot or no path. If |
Any
|
returns |
Source code in gradiend/visualizer/convergence.py
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 | |