Exemple #1
0
def ignored_nodes(A, B, C):
    xA, yA = load(A)
    xB, yB = load(B)
    xC, yC = load(C)
    plt.figure()
    plt.plot(xA, np.squeeze(yA), '--', label="$CF_{th}=0.3$")
    plt.plot(xB, np.squeeze(yB), '-.', label="$CF_{th}=0.6$")
    plt.plot(xC, np.squeeze(yC), '-', label="$CF_{th}=0.9$")
    plt.ylabel("Accuracy")
    plt.xlabel("Communication rounds")
    plt.legend(loc='best', shadow=True)
    plt.show()
Exemple #2
0
def banned_nodes(A, B, C, D):
    xA, yA = load(A)
    xB, yB = load(B)
    xC, yC = load(C)
    xD, yD = load(D)
    plt.figure()
    plt.plot(xA, np.squeeze(yA), label="Ban threshold $\epsilon=-0.0$")
    # plt.plot(xB, np.squeeze(yB), label="Ban threshold $\epsilon=-0.1$")
    plt.plot(xC, np.squeeze(yC), label="Ban threshold $\epsilon=-0.2$")
    # plt.plot(xD, np.squeeze(yD), label="Ban threshold $\epsilon=-0.3$")
    plt.ylabel("Accuracy")
    # plt.ylabel("STD accuracy")
    plt.xlabel("Communication rounds")
    plt.legend(loc='best', shadow=True)
    plt.show()
Exemple #3
0
def graph_sparsity(N, C, F):
    xN, yN = load(N)
    yN = np.poly1d(np.polyfit(xN, yN, 5))(xN)
    xC, yC = load(C)
    yC = np.poly1d(np.polyfit(xC, yC, 5))(xC)
    xF, yF = load(F)
    yF = np.poly1d(np.polyfit(xF, yF, 5))(xF)
    plt.figure()
    plt.plot(xN, np.squeeze(yN), label=f"MP without confidence")
    plt.plot(xC, np.squeeze(yC), label=f"MP with confidence")
    plt.plot(xF, np.squeeze(yF), label=f"MP with contribution factor")
    plt.ylabel("Loss")
    plt.xlabel("CR")
    plt.legend(loc='best', shadow=True)
    plt.show()
Exemple #4
0
def communication_rounds(N, C, F, ylabel="Test accuracy", xlabel="Communication rounds"):
    xN, yN = load(N)
    xC, yC = load(C)
    xF, yF = load(F)

    # yN = np.poly1d(np.polyfit(xN, yN, 5))(xN)
    # yC = np.poly1d(np.polyfit(xC, yC, 5))(xC)
    # yF = np.poly1d(np.polyfit(xF, yF, 5))(xF)

    plt.figure()
    plt.plot(xN, np.squeeze(yN), '--', label=f"MP without confidence")
    plt.plot(xC, np.squeeze(yC), '-.', label=f"MP with confidence")
    plt.plot(xF, np.squeeze(yF), label=f"CDPL")
    plt.rc('legend', fontsize=14)
    plt.ylabel(ylabel, fontsize=14)
    plt.xlabel(xlabel, fontsize=14)
    plt.legend(loc='best', shadow=True)
    plt.show()
Exemple #5
0
def contribution_factor(F, ylabel="Test accuracy"):
    x, y, z = load(F)
    plt.figure()
    plt.plot(x, np.squeeze(y), '-.', label=f"Banned peers")
    plt.plot(x, np.squeeze(z), '-', label=f"Ignored exchanges")
    plt.ylabel("")
    plt.xlabel("Communication rounds")
    plt.legend(loc='best', shadow=True)
    plt.show()
Exemple #6
0
def byzantine_metrics(file):
    x, y = load(file)
    accuracy, precision, recall, f_score = y
    plt.figure()
    plt.plot(x, np.squeeze(precision), '-.', label=f"Precision")
    plt.plot(x, np.squeeze(recall), ':', label=f"Recall")
    plt.plot(x, np.squeeze(f_score), '-', label=f"F1 score")
    plt.ylabel("")  # "STD accuracy"
    plt.xlabel("Communication rounds")
    plt.legend(loc='best', shadow=True)
    plt.show()
Exemple #7
0
def figure(f, c):
    protocol = c['protocol']
    if protocol == "MP":
        if c["args"]["protocol"]["confidence"]:
            protocol += "with confidence"
        else:
            protocol += "without confidence"

    xa, ya = load(f)
    plt.figure()
    plt.plot(xa, np.squeeze(ya), label=protocol)
    plt.legend(loc='lower right', shadow=True)
    plt.show()
Exemple #8
0
def byz_metrics():
    # Data unbalancedness
    x = np.arange(0, 1.04, 0.04)
    a = [20.97522270704118, 21.217673384474576, 20.876454631019296, 21.07826777996672, 21.349780447038157,
         21.393942478768825, 21.532803030065228, 22.657205686154647, 22.29665183020926, 23.027300121823586,
         22.815068476884967, 25.73017628615337, 23.944403332203606, 24.04844875188948, 23.31627348386516,
         25.974550614373058, 23.780625897295366, 24.44231845263808, 25.896590814062524, 24.464179877845577,
         24.831684693585732, 25.468797224581778, 25.438998259407548, 26.469847090726958, 24.18340451113953,
         26.848631982188593]
    b = [20.834537506078362, 21.433614423111706, 22.0139343141721, 22.74375941314483, 22.905046101844015,
         23.129726106403552, 23.35440611096309, 23.918826666255757, 25.65756239676712, 26.420161782205664,
         27.000853838280477, 24.592526709428405, 26.60440273322162, 30.25508491601425, 29.988037864725424,
         26.338992220441718, 28.337370576934077, 29.428795411552308, 29.621630315260447, 30.64375491902934,
         27.363785140923586, 32.34280675793754, 27.237769001749943, 25.916013654476387, 27.107113341901684,
         30.72455463578075]
    c = [21.40099975594494, 22.381069892432663, 22.0139343141721, 21.537095279233423, 22.649897579106515,
         22.535125479758758, 22.144784384827553, 23.30744757975546, 24.50233010582157, 24.183163729342905,
         23.967503769894346, 24.251919436403554, 24.71006291947645, 24.510613321449696, 24.499526616436576,
         25.366167460744677, 24.8212616425998, 24.599566315818226, 23.148352572042786, 25.52913222563778,
         25.586813645708357, 25.824018236341036, 27.8224110516684, 26.550603292850663, 27.892855528971932,
         25.531583204434444]

    # Graph sparsity
    a1 = [15.686966777270044, 16.010875259847474, 19.316491140967777, 21.57121087522782, 22.47766401440054,
          22.842883932879676, 27.634236873516045, 28.35572477967493, 30.766254622484155, 31.78035720014011,
          31.52420093188252, 34.76508207143912, 35.49499611906782, 35.36667615833082, 38.331093734563865,
          40.10024479773742, 40.35297210086058, 39.86334952207632, 42.41329244243512, 43.13970940637516,
          42.10771534859562, 44.11206701013951, 42.27749177807368, 42.538003148177026, 42.94904806697376,
          42.4739993299398, ]
    b2 = [15.344067528659018, 14.703704230041932, 18.101967916102446, 23.790547395495615, 26.218572077454148,
          28.431676973387724, 32.455284586574635, 39.691267270606566, 38.15690411263445, 43.581695474951275,
          43.71638207876443, 48.148541429589145, 44.916286537338856, 48.4026884300349, 53.69972405076261,
          52.71665533661079, 59.408636208264234, 60.03378808584248, 64.64492768338604, 63.260399932357075,
          65.33017469288968, 65.77508494973269, 64.47297896379644, 63.371741518683294, 66.13253708221916,
          62.58157533473175, ]
    c3 = [15.707690213668181, 15.098622551213772, 18.579555214862864, 20.923859528130784, 22.50205320014141,
          24.40904152186545, 27.417010791385295, 30.218323560555007, 31.990325279434156, 35.02001299334454,
          33.555830402865034, 36.67699782981615, 37.96788150302173, 38.06627913014085, 41.08966669323188,
          42.55031007470284, 44.68463634463381, 45.15483678247006, 44.823045978069224, 46.43927294489728,
          45.638875187028745, 47.2930852687084, 46.58889430287625, 45.95703884879189, 44.427697092408366,
          45.5605535372266, ]

    f = [14.879170795699618, 15.144682579117047, 14.990330106270667, 15.182636406344445, 14.944507067911577,
         15.397161710368124, 16.00506915433506, 14.234978263497363, 15.963074843091158, 16.345626592844443,
         15.63737320615790]
    c = [14.290162621326573, 16.11264965334899, 16.642167400277998, 16.829890009970676, 17.122654607689057,
         20.51235593842737, 16.561278432687946, 21.58827265876344, 17.02554882177909, 22.090620759919176,
         19.31665368788403]
    n = [14.570599684609773, 14.86373844206828, 15.101173542879739, 14.153226244863541, 14.313678725978708,
         16.73495917528062, 15.219717354289013, 15.439753880550942, 15.101713512852335, 14.503741257420867,
         15.156022787187679]
    x = np.arange(0, 1.01, 0.1)
    save("data_unbalancedness_50_NCF", (x, n, c, f))

    x, a, b, c = load("data_unbalancedness_50_NCF")

    a = np.poly1d(np.polyfit(x, a, 5))(x)
    b = np.poly1d(np.polyfit(x, b, 5))(x)
    c = np.poly1d(np.polyfit(x, c, 5))(x)

    plt.figure()
    plt.plot(x, np.squeeze(a), '-.', label=f"MP without confidence")
    plt.plot(x, np.squeeze(b), '--', label=f"MP with confidence")
    plt.plot(x, np.squeeze(c), '-', label=f"MP with contribution factor")
    plt.ylabel("Total loss")
    plt.xlabel("Graph density")
    # plt.xlabel("Width $\epsilon$")
    plt.legend(loc='best', shadow=True)
    plt.show()