def view_label_matrix(L, colorbar=True):
    """Display an [n, m] matrix of labels"""
    L = L.todense() if sparse.issparse(L) else L
    plt.imshow(L, aspect="auto")
    plt.title("Label Matrix")
    if colorbar:
        labels = sorted(np.unique(np.asarray(L).reshape(-1, 1).squeeze()))
        boundaries = np.array(labels + [max(labels) + 1]) - 0.5
        plt.colorbar(boundaries=boundaries, ticks=labels)
    plt.show()
def view_label_matrix ( L , colorbar = True ) : L = L . todense ( ) if sparse . issparse ( L ) else L plt . imshow ( L , aspect = "auto" ) plt . title ( "Label Matrix" ) if colorbar : labels = sorted ( np . unique ( np . asarray ( L ) . reshape ( - 1 , 1 ) . squeeze ( ) ) ) boundaries = np . array ( labels + [ max ( labels ) + 1 ] ) - 0.5 plt . colorbar ( boundaries = boundaries , ticks = labels ) plt . show ( )
Display an [n, m] matrix of labels