Exemple #1
0
def vari_confidence_ER(z, cutoff):
    x, y = vari_confidence_mult(z, cutoff, 0)
    x = np.array(x)
    b, m = polyfit(x, y, 1)
    plt.plot(x, y, 'ro', markersize=3)
    save_plot_custom("confidence ER")
    plt.clf()
Exemple #2
0
def loss(history):
    history_dict = history.history
    loss_values = history_dict['loss']
    val_loss_values = history_dict['val_loss']
    epochs = range(1, len(loss_values) + 1)
    plt.plot(epochs, loss_values, 'bo', label='Training loss')
    plt.plot(epochs, val_loss_values, 'b', label='Validation loss')
    plt.title('Training and validation loss')
    plt.xlabel('Epochs')
    plt.ylabel('Loss')
    plt.legend()
    save_plot_custom("Loss")
Exemple #3
0
def accuracy(history):
    history_dict = history.history
    acc_values = history_dict['acc'] 
    val_acc_values = history_dict['val_acc']
    plt.clf()
    loss_values = history_dict['loss']
    epochs = range(1, len(loss_values) + 1)
    plt.plot(epochs, acc_values, 'bo', label='Training acc')
    plt.plot(epochs, val_acc_values, 'b', label='Validation acc')
    plt.title('Training and validation Accuracy')
    plt.xlabel('Epochs')
    plt.ylabel('acc')
    plt.legend()
    save_plot_custom("Accuracy")
Exemple #4
0
def colored_contamination_ER(sizes, predictions, labels, cutoff):
    predictions = predictions.reshape(predictions.shape[0], )
    dset = list(zip(sizes, predictions, labels))
    bins, conf = vari_confidence_mult(dset, cutoff, ER_LABEL)
    contamination = []
    acontamination = []
    for i in range(len(bins)):
        contamination = contamination + list(
            filter(
                lambda z: z[0] == bins[i] and z[1] < conf[i] and z[2] ==
                NR_LABEL, dset))
        acontamination = acontamination + list(
            filter(
                lambda z: z[0] == bins[i] and z[1] > conf[i] and z[2] ==
                NR_LABEL, dset))
    if contamination:
        x = list(zip(*contamination))[0]
        y1 = list(zip(*contamination))[1]
    else:
        x, y1 = [], []
    if acontamination:
        ax = list(zip(*acontamination))[0]
        ay1 = list(zip(*acontamination))[1]
    else:
        ax, ay1 = [], []
    plt.plot(x,
             y1,
             'go',
             markersize=3,
             label='NR in ' + str(cutoff) + ' ER confidence')
    plt.plot(ax,
             ay1,
             'bo',
             markersize=3,
             label='NR outside ' + str(cutoff) + ' ER confidence')
    plt.plot(bins,
             conf,
             'ro',
             markersize=3,
             label=str(cutoff) + ' ER confidence')
    plt.legend(loc='best')
    save_plot_custom("colored_contamination_ER")
    plt.clf()
Exemple #5
0
def NR_contamination(sizes, predictions, labels, cutoff):
    predictions = predictions.reshape(predictions.shape[0], )
    dset = list(zip(sizes, predictions, labels))
    bins, conf = vari_confidence_mult(dset, 1 - cutoff, NR_LABEL)
    contamination = []
    for i in range(len(bins)):
        contamination = contamination + [
            len(
                list(
                    filter(
                        lambda z: z[0] == bins[i] and z[1] > conf[i] and z[2]
                        == ER_LABEL, dset)))
        ]
    plt.plot(bins,
             contamination,
             'go',
             markersize=3,
             label='Number of contamination points')
    plt.legend(loc='best')
    save_plot_custom("contamination_NR " + str(sum(contamination)) +
                     " contamination points")
    plt.clf()