def draw_sample_correctmatrix(datasettxt, sortedBuckets, incorrectmatix, dataset, cmap=None):
    n_maxsamples = 8
    n_labels = len(sortedBuckets)
    fig = plt.figure(figsize=((n_maxsamples * 1.8), n_labels))
    w_ratios = [1 for n in range(n_maxsamples)]
    w_ratios[:0] = [int((n_maxsamples * 0.8))]
    h_ratios = [1 for n in range(n_labels)]
    time.sleep(1)
    grid = gridspec.GridSpec(n_labels, (n_maxsamples + 1), wspace=0.0, hspace=0.0, width_ratios=w_ratios, height_ratios=h_ratios)
    labelset_pbar = tqdm(range(n_labels), desc=datasettxt, unit='labels')
    for a in labelset_pbar:
        cclassId = incorrectmatrix[sortedBuckets[((n_labels - a) - 1)]]['correct']
        pclassId = incorrectmatrix[sortedBuckets[((n_labels - a) - 1)]]['predicted']
        cdescription = classLabelList[(classLabelList.ClassId == cclassId)].SignName.to_string(header=False, index=False)
        pdescription = classLabelList[(classLabelList.ClassId == pclassId)].SignName.to_string(header=False, index=False)
        count = incorrectmatrix[sortedBuckets[((n_labels - a) - 1)]]['count']
        for b in range((n_maxsamples + 1)):
            i = ((a * (n_maxsamples + 1)) + b)
            ax = plt.Subplot(fig, grid[i])
            if (b == 0):
                ax.annotate(('CClassId %d (%d): %s\nPClassId %d: %s' % (cclassId, count, cdescription, pclassId, pdescription)), xy=(0, 0), xytext=(0.0, 0.3))
                ax.set_xticks([])
                ax.set_yticks([])
                fig.add_subplot(ax)
            else:
                if ((b - 1) < count):
                    image = dataset[incorrectmatrix[sortedBuckets[((n_labels - a) - 1)]]['samples'][(b - 1)]]
                    if (cmap == None):
                        ax.imshow(image)
                    else:
                        ax.imshow(image, cmap=cmap)
                ax.set_xticks([])
                ax.set_yticks([])
                fig.add_subplot(ax)
        if (a == (n_labels - 1)):
            all_axes = fig.get_axes()
            for ax in all_axes:
                for sp in ax.spines.values():
                    sp.set_visible(False)
    plt.show()
def draw_sample_correctmatrix(datasettxt, sortedBuckets, incorrectmatix, dataset, cmap=None):
    n_maxsamples = 8
    n_labels = len(sortedBuckets)
    fig = plt.figure(figsize=((n_maxsamples * 1.8), n_labels))
    w_ratios = [1 for n in range(n_maxsamples)]
    w_ratios[:0] = [int((n_maxsamples * 0.8))]
    h_ratios = [1 for n in range(n_labels)]
    time.sleep(1)
    grid = gridspec.GridSpec(n_labels, (n_maxsamples + 1), wspace=0.0, hspace=0.0, width_ratios=w_ratios, height_ratios=h_ratios)
    labelset_pbar = tqdm(range(n_labels), desc=datasettxt, unit='labels')
    for a in labelset_pbar:
        cclassId = incorrectmatrix[sortedBuckets[((n_labels - a) - 1)]]['correct']
        pclassId = incorrectmatrix[sortedBuckets[((n_labels - a) - 1)]]['predicted']
        cdescription = classLabelList[(classLabelList.ClassId == cclassId)].SignName.to_string(header=False, index=False)
        pdescription = classLabelList[(classLabelList.ClassId == pclassId)].SignName.to_string(header=False, index=False)
        count = incorrectmatrix[sortedBuckets[((n_labels - a) - 1)]]['count']
        for b in range((n_maxsamples + 1)):
            i = ((a * (n_maxsamples + 1)) + b)
            ax = plt.Subplot(fig, grid[i])
            if (b == 0):
                ax.annotate(('CClassId %d (%d): %s\nPClassId %d: %s' % (cclassId, count, cdescription, pclassId, pdescription)), xy=(0, 0), xytext=(0.0, 0.3))
                ax.set_xticks([])
                ax.set_yticks([])
                fig.add_subplot(ax)
            else:
                if ((b - 1) < count):
                    image = dataset[incorrectmatrix[sortedBuckets[((n_labels - a) - 1)]]['samples'][(b - 1)]]
                    if (cmap == None):
                        ax.imshow(image)
                    else:
                        ax.imshow(image, cmap=cmap)
                ax.set_xticks([])
                ax.set_yticks([])
                fig.add_subplot(ax)
        if (a == (n_labels - 1)):
            all_axes = fig.get_axes()
            for ax in all_axes:
                for sp in ax.spines.values():
                    sp.set_visible(False)
    plt.show()