mmaction/core/evaluation/accuracy.py
def plot_confusion_matrix(cm, class_names, figsize=(10,10), save_path=None, normalize=False):
    """
    Returns a matplotlib figure containing the plotted confusion matrix.

    Args:
        cm (array, shape = [n, n]): a confusion matrix of integer classes
        class_names (array, shape = [n]): String names of the integer classes
        figsize: figure pannel size
        save_path: the path to save the confusion matrix as an image
        normalize: normalized or not
    Returns:
        figure: matplotlib figure of the confusion matrix
    """
    figure = plt.figure(figsize=figsize)
    plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues)
    plt.title("Confusion matrix")
    plt.colorbar()
    tick_marks = np.arange(len(class_names))
    plt.xticks(tick_marks, class_names, rotation=90)
    plt.yticks(tick_marks, class_names)

    # Use white text if squares are dark; otherwise black.
    threshold = cm.max() / 2.
    for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
        color = "white" if cm[i, j] > threshold else "black"
        if normalize:
            if cm[i,j] == 0:
                number = '0'
            else:
                number = '{:0.1f}'.format(100*cm[i, j])
        else:
            number = cm[i,j]        
        plt.text(j, i, number, horizontalalignment="center", color=color)

    plt.tight_layout()
    plt.ylabel('True label')
    plt.xlabel('Predicted label')

    if save_path:
        plt.savefig(save_path, format='jpg')
    
    return figure

    Returns a matplotlib figure containing the plotted confusion matrix.

    Args:
        cm (array, shape = [n, n]): a confusion matrix of integer classes
        class_names (array, shape = [n]): String names of the integer classes
        figsize: figure pannel size
        save_path: the path to save the confusion matrix as an image
        normalize: normalized or not
    Returns:
        figure: matplotlib figure of the confusion matrix
    
Returns a matplotlib figure containing the plotted confusion matrix.
Returns a matplotlib figure containing the plotted confusion matrix .
def plot_confusion_matrix(cm, class_names, figsize=(10,10), save_path=None, normalize=False):
    figure = plt.figure(figsize=figsize)
    plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues)
    plt.title("Confusion matrix")
    plt.colorbar()
    tick_marks = np.arange(len(class_names))
    plt.xticks(tick_marks, class_names, rotation=90)
    plt.yticks(tick_marks, class_names)
    threshold = cm.max() / 2.
    for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
        color = "white" if cm[i, j] > threshold else "black"
        if normalize:
            if cm[i,j] == 0:
                number = '0'
            else:
                number = '{:0.1f}'.format(100*cm[i, j])
        else:
            number = cm[i,j]        
        plt.text(j, i, number, horizontalalignment="center", color=color)
    plt.tight_layout()
    plt.ylabel('True label')
    plt.xlabel('Predicted label')
    if save_path:
        plt.savefig(save_path, format='jpg')
    return figure
def plot_confusion_matrix ( cm , class_names , figsize = ( 10 , 10 ) , save_path = None , normalize = False ) : figure = plt . figure ( figsize = figsize ) plt . imshow ( cm , interpolation = 'nearest' , cmap = plt . cm . Blues ) plt . title ( "Confusion matrix" ) plt . colorbar ( ) tick_marks = np . arange ( len ( class_names ) ) plt . xticks ( tick_marks , class_names , rotation = 90 ) plt . yticks ( tick_marks , class_names ) threshold = cm . max ( ) / 2. for i , j in itertools . product ( range ( cm . shape [ 0 ] ) , range ( cm . shape [ 1 ] ) ) : color = "white" if cm [ i , j ] > threshold else "black" if normalize : if cm [ i , j ] == 0 : number = '0' else : number = '{:0.1f}' . format ( 100 * cm [ i , j ] ) else : number = cm [ i , j ] plt . text ( j , i , number , horizontalalignment = "center" , color = color ) plt . tight_layout ( ) plt . ylabel ( 'True label' ) plt . xlabel ( 'Predicted label' ) if save_path : plt . savefig ( save_path , format = 'jpg' ) return figure
Returns a matplotlib figure containing the plotted confusion matrix.
Returns a matplotlib figure containing the plotted confusion matrix .
"""
    Returns a matplotlib figure containing the plotted confusion matrix.

    Args:
        cm (array, shape = [n, n]): a confusion matrix of integer classes
        class_names (array, shape = [n]): String names of the integer classes
        figsize: figure pannel size
        save_path: the path to save the confusion matrix as an image
        normalize: normalized or not
    Returns:
        figure: matplotlib figure of the confusion matrix
    """ # Use white text if squares are dark; otherwise black.
matplotlib figure of the confusion matrix
matplotlib figure of the confusion matrix
figure
cm
a confusion matrix of integer classes
a confusion matrix of integer classes
class_names
String names of the integer classes
String names of the integer classes
figsize
figure pannel size
figure pannel size
save_path
the path to save the confusion matrix as an image
the path to save the confusion matrix as an image
normalize
normalized or not
normalized or not