Plot training accuracy curves. :param performances: Lists of training accuracy estimates per voting scheme. :param ax: Used for re-drawing the performance plot. :param figsize: Horizontal, vertical figure size in inches. :param x_scale: scaling factor for the x axis, equal to t
(
performances: Dict[str, List[float]],
ax: Optional[Axes] = None,
figsize: Tuple[int, int] = (7, 4),
x_scale: int = 1,
save: Optional[str] = None,
)
| 579 | |
| 580 | |
| 581 | def plot_performance( |
| 582 | performances: Dict[str, List[float]], |
| 583 | ax: Optional[Axes] = None, |
| 584 | figsize: Tuple[int, int] = (7, 4), |
| 585 | x_scale: int = 1, |
| 586 | save: Optional[str] = None, |
| 587 | ) -> Axes: |
| 588 | # language=rst |
| 589 | """ |
| 590 | Plot training accuracy curves. |
| 591 | |
| 592 | :param performances: Lists of training accuracy estimates per voting scheme. |
| 593 | :param ax: Used for re-drawing the performance plot. |
| 594 | :param figsize: Horizontal, vertical figure size in inches. |
| 595 | :param x_scale: scaling factor for the x axis, equal to the number of examples per performance measure |
| 596 | :param save: file name to save fig, if None = not saving fig. |
| 597 | :return: Used for re-drawing the performance plot. |
| 598 | """ |
| 599 | |
| 600 | if save is not None: |
| 601 | plt.ioff() |
| 602 | _, ax = plt.subplots(figsize=figsize) |
| 603 | |
| 604 | for scheme in performances: |
| 605 | ax.plot( |
| 606 | [n * x_scale for n in range(len(performances[scheme]))], |
| 607 | [p for p in performances[scheme]], |
| 608 | label=scheme, |
| 609 | ) |
| 610 | |
| 611 | ax.set_ylim([0, 100]) |
| 612 | ax.set_title("Estimated classification accuracy") |
| 613 | ax.set_xlabel("No. of examples") |
| 614 | ax.set_ylabel("Accuracy") |
| 615 | ax.set_yticks(range(0, 110, 10)) |
| 616 | ax.legend() |
| 617 | |
| 618 | plt.savefig(save, bbox_inches="tight") |
| 619 | plt.close() |
| 620 | plt.ion() |
| 621 | else: |
| 622 | if not ax: |
| 623 | _, ax = plt.subplots(figsize=figsize) |
| 624 | else: |
| 625 | ax.clear() |
| 626 | |
| 627 | for scheme in performances: |
| 628 | ax.plot( |
| 629 | [n * x_scale for n in range(len(performances[scheme]))], |
| 630 | [p for p in performances[scheme]], |
| 631 | label=scheme, |
| 632 | ) |
| 633 | |
| 634 | ax.set_ylim([0, 100]) |
| 635 | ax.set_title("Estimated classification accuracy") |
| 636 | ax.set_xlabel("No. of examples") |
| 637 | ax.set_ylabel("Accuracy") |
| 638 | ax.set_yticks(range(0, 110, 10)) |
no test coverage detected