diff options
author | 2019-05-27 23:30:42 -0400 | |
---|---|---|
committer | 2019-05-27 23:30:42 -0400 | |
commit | d1f199a161e2441d428f8db196de98a28ed41fa9 (patch) | |
tree | 624a78023cb58e21171732de40143806560ad90c /Metrics | |
parent | fix the null pointer error when trying reproducing the generation procedure (diff) | |
download | VIATRA-Generator-d1f199a161e2441d428f8db196de98a28ed41fa9.tar.gz VIATRA-Generator-d1f199a161e2441d428f8db196de98a28ed41fa9.tar.zst VIATRA-Generator-d1f199a161e2441d428f8db196de98a28ed41fa9.zip |
added plot median ks distance line
Diffstat (limited to 'Metrics')
-rw-r--r-- | Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance.ipynb | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance.ipynb b/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance.ipynb index 9fad79d7..c7bf9817 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance.ipynb +++ b/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance.ipynb | |||
@@ -27,7 +27,8 @@ | |||
27 | "import readCSV as reader\n", | 27 | "import readCSV as reader\n", |
28 | "import ipywidgets as widgets\n", | 28 | "import ipywidgets as widgets\n", |
29 | "import matplotlib.pyplot as plt\n", | 29 | "import matplotlib.pyplot as plt\n", |
30 | "import random\n" | 30 | "import random\n", |
31 | "import numpy as np\n" | ||
31 | ] | 32 | ] |
32 | }, | 33 | }, |
33 | { | 34 | { |
@@ -87,11 +88,51 @@ | |||
87 | " distance += value\n", | 88 | " distance += value\n", |
88 | " \n", | 89 | " \n", |
89 | " distance = distance / len(targets)\n", | 90 | " distance = distance / len(targets)\n", |
90 | " return distance" | 91 | " return distance\n" |
91 | ] | 92 | ] |
92 | }, | 93 | }, |
93 | { | 94 | { |
94 | "cell_type": "markdown", | 95 | "cell_type": "markdown", |
96 | "source": [ | ||
97 | "* Find the median ks distance of the same number of nodes" | ||
98 | ], | ||
99 | "metadata": { | ||
100 | "collapsed": false, | ||
101 | "pycharm": { | ||
102 | "name": "#%% md\n" | ||
103 | } | ||
104 | } | ||
105 | }, | ||
106 | { | ||
107 | "cell_type": "code", | ||
108 | "execution_count": null, | ||
109 | "outputs": [], | ||
110 | "source": [ | ||
111 | "def find_median(x, metric_distances):\n", | ||
112 | " distance_dic = {}\n", | ||
113 | " for index, num_of_nodes in enumerate(x):\n", | ||
114 | " if num_of_nodes[0] not in distance_dic:\n", | ||
115 | " distance_dic[num_of_nodes[0]] = []\n", | ||
116 | " distance_dic[num_of_nodes[0]].append(metric_distances[index])\n", | ||
117 | " median_x = []\n", | ||
118 | " y = []\n", | ||
119 | " for num_of_nodes, distances in distance_dic.items():\n", | ||
120 | " median_x.append(num_of_nodes)\n", | ||
121 | " y.append(np.median(distances))\n", | ||
122 | " order = np.argsort(median_x)\n", | ||
123 | " median_x = np.array(median_x)[order]\n", | ||
124 | " median_y = np.array(y)[order]\n", | ||
125 | " return median_x, median_y\n" | ||
126 | ], | ||
127 | "metadata": { | ||
128 | "collapsed": false, | ||
129 | "pycharm": { | ||
130 | "name": "#%%\n" | ||
131 | } | ||
132 | } | ||
133 | }, | ||
134 | { | ||
135 | "cell_type": "markdown", | ||
95 | "metadata": {}, | 136 | "metadata": {}, |
96 | "source": [ | 137 | "source": [ |
97 | "* Plot Diagram" | 138 | "* Plot Diagram" |
@@ -110,6 +151,9 @@ | |||
110 | " graph = plt.figure(id,figsize=(18, 10))\n", | 151 | " graph = plt.figure(id,figsize=(18, 10))\n", |
111 | " plt.title(title)\n", | 152 | " plt.title(title)\n", |
112 | " plt.plot(x, metric_distances, color='red', linestyle='', marker='o',alpha=0.7)\n", | 153 | " plt.plot(x, metric_distances, color='red', linestyle='', marker='o',alpha=0.7)\n", |
154 | " #plot ks distance median\n", | ||
155 | " median_x, median_y = find_median(x, metric_distances)\n", | ||
156 | " plt.plot(median_x, median_y, color='black',marker='o')\n", | ||
113 | " for i in range(0, len(lines)):\n", | 157 | " for i in range(0, len(lines)):\n", |
114 | " line_infos = retrive_info_from_list(lambda a: infos[a], lines[i])\n", | 158 | " line_infos = retrive_info_from_list(lambda a: infos[a], lines[i])\n", |
115 | " line_y = retrive_info_from_list(metric_selector, line_infos)\n", | 159 | " line_y = retrive_info_from_list(metric_selector, line_infos)\n", |
@@ -434,8 +478,17 @@ | |||
434 | "nbconvert_exporter": "python", | 478 | "nbconvert_exporter": "python", |
435 | "pygments_lexer": "ipython3", | 479 | "pygments_lexer": "ipython3", |
436 | "version": "3.7.3" | 480 | "version": "3.7.3" |
481 | }, | ||
482 | "pycharm": { | ||
483 | "stem_cell": { | ||
484 | "cell_type": "raw", | ||
485 | "source": [], | ||
486 | "metadata": { | ||
487 | "collapsed": false | ||
488 | } | ||
489 | } | ||
437 | } | 490 | } |
438 | }, | 491 | }, |
439 | "nbformat": 4, | 492 | "nbformat": 4, |
440 | "nbformat_minor": 2 | 493 | "nbformat_minor": 2 |
441 | } | 494 | } \ No newline at end of file |