From 98e0479f26ce0bc54016c4fba8e74e3223203b9a Mon Sep 17 00:00:00 2001 From: 20001LastOrder Date: Wed, 5 Jun 2019 11:38:23 -0400 Subject: plotting for metrics during generation --- .../metrics_plot/model comparison/input/.gitignore | 3 + .../output/Human-Viatra (30 nodes)-/MPC.png | Bin 0 -> 99670 bytes .../Human-Viatra (30 nodes)-/Node Activity.png | Bin 0 -> 85981 bytes .../output/Human-Viatra (30 nodes)-/Out Degree.png | Bin 0 -> 78151 bytes .../model comparison/src/plot_ks_stats.py | 98 ++++++++++ .../output/Human-viatraEvolve-/MPC.png | Bin 114616 -> 0 bytes .../output/Human-viatraEvolve-/Node Activity.png | Bin 92967 -> 0 bytes .../output/Human-viatraEvolve-/Out Degree.png | Bin 118164 -> 0 bytes .../src/metrics_distance_with_selector.ipynb | 204 ++++++++++++++++++--- .../metrics_plot/utils/GraphType.py | 29 +++ .../metrics_plot/utils/constants.py | 25 +++ .../metrics_plot/utils/readCSV.py | 169 +++++++++++++++++ 12 files changed, 506 insertions(+), 22 deletions(-) create mode 100644 Metrics/Metrics-Calculation/metrics_plot/model comparison/input/.gitignore create mode 100644 Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/MPC.png create mode 100644 Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Node Activity.png create mode 100644 Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Out Degree.png create mode 100644 Metrics/Metrics-Calculation/metrics_plot/model comparison/src/plot_ks_stats.py delete mode 100644 Metrics/Metrics-Calculation/metrics_plot/output/Human-viatraEvolve-/MPC.png delete mode 100644 Metrics/Metrics-Calculation/metrics_plot/output/Human-viatraEvolve-/Node Activity.png delete mode 100644 Metrics/Metrics-Calculation/metrics_plot/output/Human-viatraEvolve-/Out Degree.png create mode 100644 Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py create mode 100644 Metrics/Metrics-Calculation/metrics_plot/utils/constants.py create mode 100644 Metrics/Metrics-Calculation/metrics_plot/utils/readCSV.py (limited to 'Metrics/Metrics-Calculation/metrics_plot') diff --git a/Metrics/Metrics-Calculation/metrics_plot/model comparison/input/.gitignore b/Metrics/Metrics-Calculation/metrics_plot/model comparison/input/.gitignore new file mode 100644 index 00000000..b3934b01 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/input/.gitignore @@ -0,0 +1,3 @@ +# ignore everything in this folder +* +!.gitignore \ No newline at end of file diff --git a/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/MPC.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/MPC.png new file mode 100644 index 00000000..e660f3da Binary files /dev/null and b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/MPC.png differ diff --git a/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Node Activity.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Node Activity.png new file mode 100644 index 00000000..92047e47 Binary files /dev/null and b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Node Activity.png differ diff --git a/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Out Degree.png b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Out Degree.png new file mode 100644 index 00000000..dad7483f Binary files /dev/null and b/Metrics/Metrics-Calculation/metrics_plot/model comparison/output/Human-Viatra (30 nodes)-/Out Degree.png differ diff --git a/Metrics/Metrics-Calculation/metrics_plot/model comparison/src/plot_ks_stats.py b/Metrics/Metrics-Calculation/metrics_plot/model comparison/src/plot_ks_stats.py new file mode 100644 index 00000000..2f39ca93 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/model comparison/src/plot_ks_stats.py @@ -0,0 +1,98 @@ +import os, sys +lib_path = os.path.abspath(os.path.join('..', '..', 'utils')) +sys.path.append(lib_path) +import glob +import random +from sklearn.manifold import MDS +import matplotlib.pyplot as plt +from scipy import stats +import numpy as np +from GraphType import GraphCollection + +def main(): + # read models + human = GraphCollection('../input/humanOutput/', 500, 'Human') + viatra30 = GraphCollection('../input/viatraOutput30/', 500, 'Viatra (30 nodes)') + # viatra60 = GraphCollection('../input/viatraOutput60/', 500, 'Viatra (60 nodes)') + # viatra100 = GraphCollection('../input/viatraOutput100/', 500, 'Viatra (100 nodes)') + # random = GraphCollection('../input/randomOutput/', 500, 'Random') + # alloy = GraphCollection('../input/alloyOutput/', 500, 'Alloy (30 nodes)') + + models_to_compare = [human, viatra30] + + # define output folder + outputFolder = '../output/' + + #calculate metrics + metricStat(models_to_compare, 'Node Activity', nodeActivity, 0, outputFolder) + metricStat(models_to_compare, 'Out Degree', outDegree, 1, outputFolder) + metricStat(models_to_compare, 'MPC', mpc, 2, outputFolder) + +def calculateKSMatrix(dists): + dist = [] + + for i in range(len(dists)): + dist = dist + dists[i] + matrix = np.empty((len(dist),len(dist))) + + for i in range(len(dist)): + matrix[i,i] = 0 + for j in range(i+1, len(dist)): + value, p = stats.ks_2samp(dist[i], dist[j]) + matrix[i, j] = value + matrix[j, i] = value + return matrix + + +def calculateMDS(dissimilarities): + embedding = MDS(n_components=2, dissimilarity='precomputed') + trans = embedding.fit_transform(X=dissimilarities) + return trans + +def plot(graphTypes, coords, title='',index = 0, savePath = ''): + half_length = int(coords.shape[0] / len(graphTypes)) + color = ['blue', 'red', 'green', 'yellow'] + plt.figure(index, figsize=(7, 4)) + plt.title(title) + for i in range(len(graphTypes)): + x = (coords[(i*half_length):((i+1)*half_length), 0].tolist()) + y = (coords[(i*half_length):((i+1)*half_length), 1].tolist()) + plt.plot(x, y, color=color[i], marker='o', label = graphTypes[i].name, linestyle='', alpha=0.7) + plt.legend(loc='upper right') + plt.savefig(fname = savePath, dpi=150) + #graph.show() + +def mkdir_p(mypath): + '''Creates a directory. equivalent to using mkdir -p on the command line''' + + from errno import EEXIST + from os import makedirs,path + + try: + makedirs(mypath) + except OSError as exc: # Python >2.5 + if exc.errno == EEXIST and path.isdir(mypath): + pass + else: raise + +def metricStat(graphTypes, metricName, metric, graphIndex, outputFolder): + metrics = [] + for graph in graphTypes: + metrics.append(metric(graph)) + outputFolder = outputFolder + graph.name + '-' + print('calculate' + metricName +' for ' + outputFolder) + mkdir_p(outputFolder) + out_d_coords = calculateMDS(calculateKSMatrix(metrics)) + plot(graphTypes, out_d_coords, metricName, graphIndex,outputFolder + '/'+ metricName+'.png') + +def nodeActivity(graphType): + return graphType.nas + +def outDegree(graphType): + return graphType.out_ds + +def mpc(graphType): + return graphType.mpcs + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-viatraEvolve-/MPC.png b/Metrics/Metrics-Calculation/metrics_plot/output/Human-viatraEvolve-/MPC.png deleted file mode 100644 index d819aad5..00000000 Binary files a/Metrics/Metrics-Calculation/metrics_plot/output/Human-viatraEvolve-/MPC.png and /dev/null differ diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-viatraEvolve-/Node Activity.png b/Metrics/Metrics-Calculation/metrics_plot/output/Human-viatraEvolve-/Node Activity.png deleted file mode 100644 index 4b3b187e..00000000 Binary files a/Metrics/Metrics-Calculation/metrics_plot/output/Human-viatraEvolve-/Node Activity.png and /dev/null differ diff --git a/Metrics/Metrics-Calculation/metrics_plot/output/Human-viatraEvolve-/Out Degree.png b/Metrics/Metrics-Calculation/metrics_plot/output/Human-viatraEvolve-/Out Degree.png deleted file mode 100644 index d8e01f6e..00000000 Binary files a/Metrics/Metrics-Calculation/metrics_plot/output/Human-viatraEvolve-/Out Degree.png and /dev/null differ diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance_with_selector.ipynb b/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance_with_selector.ipynb index e5868da0..a0b0ad8d 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance_with_selector.ipynb +++ b/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance_with_selector.ipynb @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -48,7 +48,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -78,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -108,7 +108,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -139,7 +139,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -149,7 +149,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -163,7 +163,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -200,7 +200,8 @@ "# Read generated models\n", "viatra_no_con_stats = readStats('../statistics/viatra_nocon_output/', 5000)\n", "viatra_con_stats = readStats('../statistics/viatra_con_output/',5000)\n", - "random_stats = readStats('../statistics/random_output/',5000)" + "random_stats = readStats('../statistics/random_output/',5000)\n", + "con_viatra_stats = readStats('../statistics/controled_viatra/',300)" ] }, { @@ -218,7 +219,8 @@ "source": [ "viatra_no_con_dic = calDistanceDic(viatra_no_con_stats, human_rep)\n", "viatra_con_dic = calDistanceDic(viatra_con_stats, human_rep)\n", - "random_dic = calDistanceDic(random_stats, human_rep)" + "random_dic = calDistanceDic(random_stats, human_rep)\n", + "con_viatra_dic = calDistanceDic(con_viatra_stats, human_rep)" ] }, { @@ -255,7 +257,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "1bdc31418d894783b36cc79c60251f00", + "model_id": "868a437468d24144926f1390cbf2acb8", "version_major": 2, "version_minor": 0 }, @@ -291,7 +293,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "78565a0ec3d740908fcea753387cfc3e", + "model_id": "e8b74fe96a45445f8062468ddf2597bf", "version_major": 2, "version_minor": 0 }, @@ -327,7 +329,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "4392eb19fe1844c4affeb62f9ba9163b", + "model_id": "c6e7e31f454a48169dac12c8aac70eef", "version_major": 2, "version_minor": 0 }, @@ -363,7 +365,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "c667f0f9dcd5494f81d95c64ad900612", + "model_id": "cebc359548f74cc8b7540ecc3876c9ee", "version_major": 2, "version_minor": 0 }, @@ -399,7 +401,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "991d8d2bfc644c82a9b079615900dc4d", + "model_id": "682beae42eef4676b11b6fe23127a44e", "version_major": 2, "version_minor": 0 }, @@ -435,7 +437,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "be65f39c2fae4c84a1d6908f3b70a86e", + "model_id": "6893b8c6e03441f89fc35bf784992ae9", "version_major": 2, "version_minor": 0 }, @@ -471,7 +473,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "1de0db5b5c8d46de958f6b43144dac54", + "model_id": "ff0e1991c69a4d77a40f57225f90295a", "version_major": 2, "version_minor": 0 }, @@ -501,13 +503,13 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "6f8fa855125b4beca603abbf801412ac", + "model_id": "838570f20bed4d8d9c618305984d19ef", "version_major": 2, "version_minor": 0 }, @@ -524,7 +526,7 @@ "" ] }, - "execution_count": 20, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -537,13 +539,13 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "b4ed2adb29004908a3799bc91bf0662b", + "model_id": "f4825f6257a74bce9dd22aac8a98effa", "version_major": 2, "version_minor": 0 }, @@ -560,7 +562,7 @@ "" ] }, - "execution_count": 23, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -571,6 +573,164 @@ "interact(plot_out_degree, lines=[[]])" ] }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [], + "source": [ + "con_viatra_stats = readStats('../statistics/controled_viatra/',5000)\n", + "con_viatra_dic = calDistanceDic(con_viatra_stats, human_rep)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Trajectories for controlled viatra solver" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [], + "source": [ + "filenames = reader.readmultiplefiles('../statistics/controled_viatra/trajectories/', 25, False)\n", + "trajectories = {}\n", + "for name in filenames:\n", + " trajectories[name] = reader.readTrajectory(name)\n", + "\n", + "w = widgets.SelectMultiple(\n", + " options = trajectories,\n", + " value = [trajectories[filenames[0]]],\n", + " description='Trajectory:',\n", + " disabled=False,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "4b60ae3859e343299badf29272f67d21", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/controled_…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def plot_out_degree(lines):\n", + " plot(con_viatra_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out_degree')\n", + "interact(plot_out_degree, lines=w)" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "8e7965d793a146d4bbc268554262eb58", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/controled_…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def plot_na(lines):\n", + " plot(con_viatra_dic, lines, 0, lambda a: a.na_distance, colors, 'Node Activity')\n", + "interact(plot_na, lines=w)" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "55a1209d0b924a39b4729228e81ee3ab", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/controled_…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def plot_mpc(lines):\n", + " plot(con_viatra_dic, lines, 0, lambda a: a.mpc_distance, colors, 'mpc')\n", + "interact(plot_mpc, lines=w)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, diff --git a/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py b/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py new file mode 100644 index 00000000..13754e80 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py @@ -0,0 +1,29 @@ +import readCSV as reader +import constants +import numpy as np + +# graph stats for a collection of graphs +class GraphCollection: + + # init with path contrain files and number of files to read reader is imported from (readCSV) + def __init__(self, path, number, name, shouldShuffle = True): + self.out_ds = [] + self.nas = [] + self.mpcs = [] + self.name = name + models = reader.readmultiplefiles(path, number, shouldShuffle) + for i in range(len(models)): + contents, out_d, na, mpc = reader.getmetrics(models[i]) + self.out_ds.append(out_d) + self.nas.append(na) + self.mpcs.append(mpc) + print(len(self.out_ds)) + +#Graph stat for one graph +class GraphStat: + # init with teh file name of the stat + def __init__(self, filename): + contents, self.out_d, self.na, self.mpc = reader.getmetrics(filename) + self.num_nodes = np.array(contents[constants.NUMBER_NODES]) + if constants.STATE_ID in contents: + self.id = (contents[constants.STATE_ID])[0] diff --git a/Metrics/Metrics-Calculation/metrics_plot/utils/constants.py b/Metrics/Metrics-Calculation/metrics_plot/utils/constants.py new file mode 100644 index 00000000..58ca7549 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/utils/constants.py @@ -0,0 +1,25 @@ +NUMBER_EDGE_TYPES = 'Number of Edge types' + +NUMBER_NODES = 'Number Of Nodes' + +OUT_DEGREE_COUNT = 'OutDegreeCount' + +OUT_DEGREE_VALUE = 'OutDegreeValue' + +NA_COUNT = 'NACount' + +NA_VALUE = 'NAValue' + +MPC_VALUE = 'MPCValue' + +MPC_COUNT = 'MPCCount' + +METAMODEL = 'Meta Mode' + +STATE_ID = 'State Id' + +HUMAN_OUT_D_REP = '../statistics/humanOutput\R_20158_run_1.csv' + +HUMAN_MPC_REP = '../statistics/humanOutput\R_2015246_run_1.csv' + +HUMAN_NA_REP = '../statistics/humanOutput\R_2016176_run_1.csv' diff --git a/Metrics/Metrics-Calculation/metrics_plot/utils/readCSV.py b/Metrics/Metrics-Calculation/metrics_plot/utils/readCSV.py new file mode 100644 index 00000000..e0402519 --- /dev/null +++ b/Metrics/Metrics-Calculation/metrics_plot/utils/readCSV.py @@ -0,0 +1,169 @@ +import numpy as np +import matplotlib.pyplot as plt +from scipy import stats +import glob +import random +import constants + +# +# read csvfile returns outdegree, node activity, mpc +# as matrix with the first row of values and second row of count +# +def readcsvfile(filename): + + contents = {} + with open(filename) as f: + for i, line in enumerate(f): + arr = line.split(',') + # if there is no element in the line, continue + if len(line) < 0: continue + # else check for contents + # if it is MPC then use float + if arr[0] == constants.MPC_VALUE: + contents[constants.MPC_VALUE] = list(map(float, arr[1:])) + # meta models are string + elif(arr[0] == constants.METAMODEL): + contents[constants.METAMODEL] = arr[1:] + # all other contants are integer + else: + contents[arr[0]] = list(map(int, arr[1:])) + f.close() + return contents + +def checkAndReshape(arr): + if len(arr.shape) < 2: + arr = np.reshape(arr, (arr.shape[0],1)) + return arr + +def readTrajectory(filename): + state_codes = [] + with open(filename) as f: + for i, line in enumerate(f): + if(line == ''): continue + state_codes.append(int(line)) + return state_codes +# +# take a matrix as input +# return the sample array +# +def getsample(dataMatrix): + data = [] + value = dataMatrix[0, :] + count = dataMatrix[1, :] + for i, v in enumerate(value): + for x in range(0, int(count[i])): + data.append(v) + return data + +def reproduceSample(values, counts): + arr = np.array([values, counts]) + return getsample(arr) + +# +# take an array of filenames as input +# return the samples of outdegree, na, mpc +# +def getmetrics(filename): + contents = readcsvfile(filename) + outdegree_sample = reproduceSample(contents[constants.OUT_DEGREE_VALUE], contents[constants.OUT_DEGREE_COUNT]) + na_sample = reproduceSample(contents[constants.NA_VALUE], contents[constants.NA_COUNT]) + mpc_sample = reproduceSample(contents[constants.MPC_VALUE], contents[constants.MPC_COUNT]) + return contents,outdegree_sample, na_sample, mpc_sample + +# +# read number of files in the given path RANDOMLY +# +def readmultiplefiles(dirName, maxNumberOfFiles, shouldShuffle = True): + list_of_files = glob.glob(dirName + '*.csv') # create the list of file + if shouldShuffle: + random.shuffle(list_of_files) + #if the number of files is out of bound then just give the whole list + file_names = list_of_files[:maxNumberOfFiles] + # print(file_names) + return file_names + + +def plotlines(x, y, ax): + l1, = ax.plot(x, y) + + +def testgetsamplesfromfiles(): + files = readmultiplefiles('../statistics/viatraOutput/', 2) + for file in files: + getmetrics(file) + +def probability(data): + sum = np.sum(data) + probabilityList = [] + for d in data: + p = d/sum + probabilityList.append(p) + a = np.array(probabilityList) + return a + + +def cumulativeProbability(p): + cdf = np.cumsum(p) + return cdf + + +def plot(): + fig, ax = plt.subplots() + fig, ax1 = plt.subplots() + fig, ax2 = plt.subplots() + fig, ax3 = plt.subplots() + fig, ax4 = plt.subplots() + fig, ax5 = plt.subplots() + list_of_files = readmultiplefiles('../statistics/iatraOutput/') + for file_name in list_of_files: + contents = readcsvfile(file_name) + outdegree = [contents[constants.OUT_DEGREE_VALUE], contents[constants.OUT_DEGREE_COUNT]] + na = [contents[constants.NA_VALUE], contents[constants.NA_COUNT]] + mpc = [contents[constants.MPC_VALUE], contents[constants.MPC_COUNT]] + outV = outdegree[0, :] + outC = outdegree[1, :] + outP = probability(outC) + outCumP = cumulativeProbability(outP) + plotlines(outV, outP, ax) + naV = na[0, :] + naC = na[1, :] + naP = probability(naC) + naCumP = cumulativeProbability(naP) + plotlines(naV, naP, ax1) + mpcV = mpc[0, :] + mpcC = mpc[1, :] + mpcP = probability(mpcC) + mpcCumP = cumulativeProbability(mpcP) + plotlines(mpcV, mpcP, ax2) + plotlines(outV, outCumP, ax3) + plotlines(naV, naCumP, ax4) + plotlines(mpcV, mpcCumP, ax5) + ax.set_xlabel('ourdegree') + ax.set_ylabel('pdf') + ax.grid() + + ax1.set_xlabel('node activity') + ax1.set_ylabel('pdf') + ax1.grid() + + ax2.set_xlabel('multiplex participation coefficient') + ax2.set_ylabel('pdf') + ax2.grid() + + ax3.set_xlabel('ourdegree') + ax3.set_ylabel('cdf') + ax3.grid() + + ax4.set_xlabel('node activity') + ax4.set_ylabel('cdf') + ax4.grid() + + ax5.set_xlabel('multiplex participation coefficient') + ax5.set_ylabel('cdf') + ax5.grid() + + plt.show() + + +# plot() + -- cgit v1.2.3-54-g00ecf