Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {
- "ExecuteTime": {
- "end_time": "2019-02-14T07:57+0000",
- "start_time": "2019-02-14T07:57+0000"
- }
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "",
- "version_major": 2,
- "version_minor": 0
- },
- "method": "display_data"
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "%classpath add mvn org.apache.commons commons-math3 3.6.1"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 59,
- "metadata": {
- "ExecuteTime": {
- "end_time": "2019-02-14T08:36+0000",
- "start_time": "2019-02-14T08:36+0000"
- }
- },
- "outputs": [
- {
- "data": {
- "text/plain": [
- "#000b7e"
- ]
- },
- "execution_count": 59,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "def randomRgbCode() {\n",
- " def rgb = new Random().nextInt(1 << 12) // A random 24-bit integer\n",
- " '#00' + Integer.toString(rgb, 16).padLeft(4, '0')\n",
- "}\n",
- "randomRgbCode()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 74,
- "metadata": {
- "ExecuteTime": {
- "end_time": "2019-02-14T16:41+0000",
- "start_time": "2019-02-14T16:41+0000"
- },
- "scrolled": true
- },
- "outputs": [
- {
- "data": {
- "text/plain": [
- "script1550162502672$_run_closure3@437165e5"
- ]
- },
- "execution_count": 74,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "import org.apache.commons.math3.stat.regression.SimpleRegression\n",
- "\n",
- "/*\n",
- "def randomRgbCode() {\n",
- " def rgb = new Random().nextInt(1 << 24) // A random 24-bit integer\n",
- " '#' + Integer.toString(rgb, 16).padLeft(6, '0')\n",
- "}\n",
- "*/\n",
- "\n",
- "def randomRgbCode() {\n",
- " def rgb = new Random().nextInt(1 << 12) // A random 24-bit integer\n",
- " '#00' + Integer.toString(rgb, 16).padLeft(4, '0')\n",
- "}\n",
- "\n",
- "@Grab('com.xlson.groovycsv:groovycsv:1.3')\n",
- "import static com.xlson.groovycsv.CsvParser.parseCsv\n",
- "\n",
- "add_data_points = { file_name,plot,runs,randomcolor -> \n",
- " \n",
- " for(num = 0; num<runs-1; num++){\n",
- " fh = new File(\"${file_name}${num}.tsv\")\n",
- " def csv_content = fh.getText('utf-8')\n",
- " data_iterator = parseCsv(csv_content, separator: ' ', readFirstLine: true)\n",
- " // println data_iterator.getClass() // class com.xlson.groovycsv.CsvIterator\n",
- "\n",
- " x = []\n",
- " y = []\n",
- "\n",
- " for (line in data_iterator) {\n",
- " x_1 = Double.parseDouble(line[0])\n",
- " y_1 = Double.parseDouble(line[1])\n",
- "\n",
- " x << x_1\n",
- " y << y_1\n",
- "\n",
- " //regression.addData(x_1,y_1)\n",
- " }\n",
- "\n",
- " def color = randomcolor ? Color.decode(randomRgbCode()) : Color.RED\n",
- " plot << new Points(x: x,y: y,color: color)\n",
- " }\n",
- "}\n",
- "\n",
- "print_paretos = { exp_name,runs ->\n",
- "\n",
- " plot = new Plot(title: \"Pareto Front\", initHeight: 200)\n",
- "\n",
- " //regression = new SimpleRegression()\n",
- "\n",
- " add_data_points(\"${exp_name}/FUN\",plot,runs,true)\n",
- "\n",
- " //regression.regress()\n",
- "\n",
- " intercept = regression.getIntercept()\n",
- " slope = regression.getSlope()\n",
- " \n",
- " println(\"Intercept: ${intercept}\")\n",
- " println(\"Slope: ${slope}\")\n",
- "\n",
- " plot << new Line(x: [0,1],y: [regression.predict(0),regression.predict(1)], width: 3, color: Color.red)\n",
- "\n",
- " return plot\n",
- "}\n",
- "\n",
- "compare_single_multi = { single_file, multi_file, runs ->\n",
- "\n",
- " plot = new Plot(title: \"Comparison\", initHeight: 200)\n",
- "\n",
- " //regression = new SimpleRegression()\n",
- "\n",
- " add_data_points(\"${single_file}/DEC\",plot,runs,false)\n",
- " add_data_points(\"${multi_file}/FUN\",plot,runs,true)\n",
- " \n",
- " //regression.regress()\n",
- "\n",
- " //intercept = regression.getIntercept()\n",
- " //slope = regression.getSlope()\n",
- " \n",
- " //println(\"Intercept: ${intercept}\")\n",
- " //println(\"Slope: ${slope}\")\n",
- "\n",
- " //plot << new Line(x: [0,1],y: [regression.predict(0),regression.predict(1)], width: 3, color: Color.red)\n",
- "\n",
- " return plot\n",
- "}"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {
- "ExecuteTime": {
- "end_time": "2019-02-11T22:54+0000",
- "start_time": "2019-02-11T22:54+0000"
- }
- },
- "outputs": [
- {
- "ename": "groovy.lang.MissingPropertyException",
- "evalue": " No such property",
- "output_type": "error",
- "traceback": [
- "\u001b[1;31mgroovy.lang.MissingPropertyException: No such property: x for class: script1549925654529\u001b[0;0m",
- "\u001b[1;31m\tat this cell line 2\u001b[0;0m",
- "\u001b[0;31m\tat com.twosigma.beakerx.groovy.evaluator.GroovyCodeRunner.runScript(GroovyCodeRunner.java:94)\u001b[0;0m",
- "\u001b[0;31m\tat com.twosigma.beakerx.groovy.evaluator.GroovyCodeRunner.call(GroovyCodeRunner.java:59)\u001b[0;0m",
- "\u001b[0;31m\tat com.twosigma.beakerx.groovy.evaluator.GroovyCodeRunner.call(GroovyCodeRunner.java:32)\u001b[0;0m"
- ]
- }
- ],
- "source": [
- "plot = new Plot(title: \"Pareto Front\", initHeight: 200)\n",
- "plot << new Points(x: x,y: y,color: Color.green)\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {
- "ExecuteTime": {
- "end_time": "2019-02-11T22:54+0000",
- "start_time": "2019-02-11T22:54+0000"
- },
- "scrolled": false
- },
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Intercept: 0.7886246425446715\n",
- "Slope: -0.21135806388698367\n",
- "Intercept: 0.7389477566186027\n",
- "Slope: -0.14569380154389486\n",
- "Intercept: 0.6759963217641969\n",
- "Slope: -0.06007280615199858\n"
- ]
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "313d1a3d-2c1c-4c47-bd8b-8ada54f05905",
- "version_major": 2,
- "version_minor": 0
- },
- "method": "display_data"
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "5665b593-0f52-4fa9-a12a-4d4338312556",
- "version_major": 2,
- "version_minor": 0
- },
- "method": "display_data"
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "88f500a8-3fc1-48c6-9932-46fa4930ca49",
- "version_major": 2,
- "version_minor": 0
- },
- "method": "display_data"
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/plain": [
- "null"
- ]
- },
- "execution_count": 6,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "plot1 = print_paretos(\"20_20_200_1549559439556\",20)\n",
- "plot2 = print_paretos(\"20_20_200_1549559804878\",20)\n",
- "plot3 = print_paretos(\"NONE\",200)\n",
- "\n",
- "display(plot1)\n",
- "display(plot2)\n",
- "display(plot3)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 28,
- "metadata": {
- "ExecuteTime": {
- "end_time": "2019-02-14T08:26+0000",
- "start_time": "2019-02-14T08:26+0000"
- }
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "ec116549-da43-4990-8e57-3a3589b7e7ba",
- "version_major": 2,
- "version_minor": 0
- },
- "method": "display_data"
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "compare_single_multi(\"Thing Study/data/Genetic_Algorithm_20_20_200_1550128953961/SingleObjectiveGrouping_20\",\"Thing Study/data/NSGAII_20_20_200_1550099845667/MultiObjectiveGrouping_20\",20)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 27,
- "metadata": {
- "ExecuteTime": {
- "end_time": "2019-02-14T08:26+0000",
- "start_time": "2019-02-14T08:26+0000"
- }
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "097ee876-2311-45d6-a198-71e1df28df6a",
- "version_major": 2,
- "version_minor": 0
- },
- "method": "display_data"
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "compare_single_multi(\"Thing Study/data/Genetic_Algorithm_20_20_200_1550128953961/SingleObjectiveGrouping_200\",\"Thing Study/data/NSGAII_20_20_200_1550099845667/MultiObjectiveGrouping_200\",20)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 75,
- "metadata": {
- "ExecuteTime": {
- "end_time": "2019-02-14T16:41+0000",
- "start_time": "2019-02-14T16:41+0000"
- }
- },
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Intercept: NaN\n",
- "Slope: NaN\n"
- ]
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "8935f6b2-a173-420d-9bdf-53f8225e3fab",
- "version_major": 2,
- "version_minor": 0
- },
- "method": "display_data"
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "plot = print_paretos(\"Thing Study/data/NSGAII_200_20_200_1550132169095/MultiObjectiveGrouping_200\",200)\n",
- "add_data_points(\"Thing Study/data/Genetic_Algorithm_20_20_200_1550128953961/SingleObjectiveGrouping_200/DEC\",plot,20,false)\n",
- "\n",
- "plot"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 73,
- "metadata": {
- "ExecuteTime": {
- "end_time": "2019-02-14T16:00+0000",
- "start_time": "2019-02-14T16:00+0000"
- },
- "scrolled": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "bb5c3ce5-ed83-4edc-8247-0d83e2c89ee8",
- "version_major": 2,
- "version_minor": 0
- },
- "method": "display_data"
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "new_plot = new Plot(title: \"Single points\", initHeight: 200)\n",
- "add_data_points(\"Thing Study/data/Genetic_Algorithm_20_20_200_1550159784855/SingleObjectiveGrouping_200/DEC\",new_plot,20,false)\n",
- "new_plot"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Groovy",
- "language": "groovy",
- "name": "groovy"
- },
- "language_info": {
- "codemirror_mode": "groovy",
- "file_extension": ".groovy",
- "mimetype": "",
- "name": "Groovy",
- "nbconverter_exporter": "",
- "version": "2.4.3"
- },
- "toc": {
- "base_numbering": 1,
- "nav_menu": {},
- "number_sections": false,
- "sideBar": false,
- "skip_h1_title": false,
- "title_cell": "Table of Contents",
- "title_sidebar": "Contents",
- "toc_cell": false,
- "toc_position": {},
- "toc_section_display": false,
- "toc_window_display": false
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement