• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ContinualAI / avalanche / 8892479082

30 Apr 2024 09:27AM UTC coverage: 51.805% (+0.05%) from 51.751%
8892479082

Pull #1633

github

web-flow
Merge 876140c8f into 6e5e3b278
Pull Request #1633: Updatable objects

248 of 436 new or added lines in 20 files covered. (56.88%)

9 existing lines in 1 file now uncovered.

15081 of 29111 relevant lines covered (51.81%)

0.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

59.26
/avalanche/evaluation/plot_utils.py
1
################################################################################
2
# Copyright (c) 2021 ContinualAI.                                              #
3
# Copyrights licensed under the MIT License.                                   #
4
# See the accompanying LICENSE file for terms.                                 #
5
#                                                                              #
6
# Date: 24/07/2021                                                             #
7
# Author(s): Antonio Carta                                                     #
8
# E-mail: contact@continualai.org                                              #
9
# Website: avalanche.continualai.org                                           #
10
################################################################################
11
import numpy as np
1✔
12
from matplotlib import pyplot as plt
1✔
13

14

15
def learning_curves_plot(all_metrics: dict):
1✔
16
    """Creates a plot with separate learning curves for each experience.
17

18
    :param all_metrics: Dictionary of metrics as returned by
19
        EvaluationPlugin.get_all_metrics
20
    :return: matplotlib figure
21
    """
22
    accs_keys = list(filter(lambda x: "Top1_Acc_Exp" in x, all_metrics.keys()))
×
23
    fig, ax = plt.subplots()
×
24
    for ak in accs_keys:
×
25
        k = ak.split("/")[-1]
×
26
        x, y = all_metrics[ak]
×
27
        plt.plot(x, y, label=k)
×
28
    ax.legend()
×
29
    ax.set_xlabel("Iterations")
×
30
    ax.set_ylabel("Experience Accuracy")
×
31
    return fig
×
32

33

34
def plot_metric_matrix(metric_matrix, title, *, ax=None, text_values=True):
1✔
35
    """Plot a matrix of metrics (e.g. forgetting over time).
36

37
    :param metric_matrix: 2D accuracy matrix with shape <time, experiences>
38
    :param title: plot title
39
    :param ax: axes to use for figure
40
    :param text_values: (bool) whether to add the value as text in each cell.
41

42
    :return: a matplotlib.Figure
43
    """
44
    if ax is None:
1✔
45
        fig, ax = plt.subplots()
1✔
46
    else:
NEW
47
        fig = ax.figure
×
48

49
    metric_matrix = np.array(metric_matrix).T
1✔
50
    ax.matshow(metric_matrix)
1✔
51
    ax.set_ylabel("Experience")
1✔
52
    ax.set_xlabel("Time")
1✔
53
    ax.set_title(title)
1✔
54

55
    if text_values:
1✔
56
        for i in range(len(metric_matrix)):
1✔
57
            for j in range(len(metric_matrix[0])):
1✔
58
                ax.text(
1✔
59
                    j,
60
                    i,
61
                    f"{metric_matrix[i][j]:.3f}",
62
                    ha="center",
63
                    va="center",
64
                    color="w",
65
                )
66
    return fig
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc