import pickle
from sklearn.metrics import rand_score
import matplotlib.pyplot as plt
import numpy as np
save_path = "Save_models/"


our_method=[];
IFCA=[];
snapshot=[];
#g_t=[0,0,0,1,1,1,2,2,2,2];
g_t=[0]*33+[1]*33+34*[2]
batch_size=256
for t in range(200):
    # with open(save_path + 'Agg_Batchwise_EXPRTD_Training_Cluster_save_for_round' + str(t)+'_bs_64', 'rb') as fp:
    #     our_method+=[rand_score(pickle.load(topfp),g_t)]
    #
    # with open(save_path + 'Agg_Batchwise_EXPRTD_Training_Cluster_inst_save_for_round' + str(t)+'_bs_64', 'rb') as fp:
    #     snapshot+=[rand_score(pickle.load(fp), g_t)]
    with open(save_path+'Mem_Agg_Batchwise_EXPRTD_Training_Cluster_save_for_round_v3'+str(t)+'_bs_'+str(batch_size), 'rb') as fp:
        our_method+=[rand_score(pickle.load(fp),g_t)]

    with open(save_path+'Mem_Agg_Batchwise_EXPRTD_Training_Cluster_inst_save_for_round_v3'+str(t)+'_bs_'+str(batch_size), 'rb') as fp:
        snapshot+=[rand_score(pickle.load(fp), g_t)]

    with open(save_path + 'C_t_ifca for round ' + str(t) + '__', 'rb') as fp:
        IFCA+=[rand_score(pickle.load(fp),g_t)]

plt.plot(np.arange(200)+1, our_method)
plt.plot(np.arange(200)+1, IFCA)
plt.plot(np.arange(200)+1, snapshot)
plt.legend(['Our method', 'IFCA', 'Snapshot'])
plt.xlabel('Communication Rounds')
plt.ylabel('Rand Score')
plt.title('Clustering Method is AHC; Batch Size 64')
plt.savefig('Clustering Plot_.png')

#
#
# our_method=[];
# snapshot=[];
#
# for t in range(60):
#     with open(save_path + 'Batchwise_EXPRTD_Training_Cluster_save_for_round' + str(t), 'rb') as fp:
#         our_method+=[rand_score(pickle.load(fp),g_t)]
#
#     with open(save_path + 'Batchwise_EXPRTD_Training_Cluster_inst_save_for_round' + str(t), 'rb') as fp:
#         snapshot+=[rand_score(pickle.load(fp), g_t)]
#
#
#
# plt.figure()
# plt.plot(np.arange(60)+1, our_method)
# plt.plot(np.arange(60)+1, snapshot)
# plt.legend(['Our method', 'Snapshot'])
# plt.xlabel('Communication Rounds')
# plt.ylabel('Rand Score')
#
# plt.title('Clustering Method is K-means')
# plt.savefig('Clustering Plot Kmeans.png')
#
