Commit 30c0ef86 by guanxing

add experiment notebook

parent 4b14471b
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2018-09-12T08:50:24.068503Z",
"start_time": "2018-09-12T08:50:23.107770Z"
}
},
"outputs": [],
"source": [
"import os\n",
"import re\n",
"import sys\n",
"sys.path.append(os.getcwd())\n",
"import shutil\n",
"\n",
"#import coref_mermaid_model as cmm\n",
"import numpy as np\n",
"from bokeh.plotting import figure, show\n",
"from bokeh.io import output_notebook"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"ExecuteTime": {
"end_time": "2018-09-12T08:31:46.323009Z",
"start_time": "2018-09-12T08:31:46.319901Z"
}
},
"outputs": [],
"source": [
"with open('/home/NewPartion/e2e-coref/precision_recall.txt','a') as f:\n",
" #f.write(str(1)+' '+str(75.39)+' '+str(59.07)+'\\n')\n",
" f.write('0 70.23 63.72'+'\\n')"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"ExecuteTime": {
"end_time": "2018-09-12T11:48:09.587465Z",
"start_time": "2018-09-12T11:48:09.448632Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.0, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5]\n"
]
},
{
"data": {
"text/html": [
"\n",
" <div class=\"bk-root\">\n",
" <a href=\"https://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
" <span id=\"3b5c2006-05d2-4799-a92c-088336212af5\">Loading BokehJS ...</span>\n",
" </div>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"\n",
"(function(root) {\n",
" function now() {\n",
" return new Date();\n",
" }\n",
"\n",
" var force = true;\n",
"\n",
" if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
" root._bokeh_onload_callbacks = [];\n",
" root._bokeh_is_loading = undefined;\n",
" }\n",
"\n",
" var JS_MIME_TYPE = 'application/javascript';\n",
" var HTML_MIME_TYPE = 'text/html';\n",
" var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
" var CLASS_NAME = 'output_bokeh rendered_html';\n",
"\n",
" /**\n",
" * Render data to the DOM node\n",
" */\n",
" function render(props, node) {\n",
" var script = document.createElement(\"script\");\n",
" node.appendChild(script);\n",
" }\n",
"\n",
" /**\n",
" * Handle when an output is cleared or removed\n",
" */\n",
" function handleClearOutput(event, handle) {\n",
" var cell = handle.cell;\n",
"\n",
" var id = cell.output_area._bokeh_element_id;\n",
" var server_id = cell.output_area._bokeh_server_id;\n",
" // Clean up Bokeh references\n",
" if (id !== undefined) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
"\n",
" if (server_id !== undefined) {\n",
" // Clean up Bokeh references\n",
" var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
" cell.notebook.kernel.execute(cmd, {\n",
" iopub: {\n",
" output: function(msg) {\n",
" var element_id = msg.content.text.trim();\n",
" Bokeh.index[element_id].model.document.clear();\n",
" delete Bokeh.index[element_id];\n",
" }\n",
" }\n",
" });\n",
" // Destroy server and session\n",
" var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
" cell.notebook.kernel.execute(cmd);\n",
" }\n",
" }\n",
"\n",
" /**\n",
" * Handle when a new output is added\n",
" */\n",
" function handleAddOutput(event, handle) {\n",
" var output_area = handle.output_area;\n",
" var output = handle.output;\n",
"\n",
" // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
" if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
" return\n",
" }\n",
"\n",
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
"\n",
" if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
" toinsert[0].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
" // store reference to embed id on output_area\n",
" output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
" }\n",
" if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
" var bk_div = document.createElement(\"div\");\n",
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
" var script_attrs = bk_div.children[0].attributes;\n",
" for (var i = 0; i < script_attrs.length; i++) {\n",
" toinsert[0].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
" }\n",
" // store reference to server id on output_area\n",
" output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
" }\n",
" }\n",
"\n",
" function register_renderer(events, OutputArea) {\n",
"\n",
" function append_mime(data, metadata, element) {\n",
" // create a DOM node to render to\n",
" var toinsert = this.create_output_subarea(\n",
" metadata,\n",
" CLASS_NAME,\n",
" EXEC_MIME_TYPE\n",
" );\n",
" this.keyboard_manager.register_events(toinsert);\n",
" // Render to node\n",
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
" render(props, toinsert[0]);\n",
" element.append(toinsert);\n",
" return toinsert\n",
" }\n",
"\n",
" /* Handle when an output is cleared or removed */\n",
" events.on('clear_output.CodeCell', handleClearOutput);\n",
" events.on('delete.Cell', handleClearOutput);\n",
"\n",
" /* Handle when a new output is added */\n",
" events.on('output_added.OutputArea', handleAddOutput);\n",
"\n",
" /**\n",
" * Register the mime type and append_mime function with output_area\n",
" */\n",
" OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
" /* Is output safe? */\n",
" safe: true,\n",
" /* Index of renderer in `output_area.display_order` */\n",
" index: 0\n",
" });\n",
" }\n",
"\n",
" // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
" if (root.Jupyter !== undefined) {\n",
" var events = require('base/js/events');\n",
" var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
"\n",
" if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
" register_renderer(events, OutputArea);\n",
" }\n",
" }\n",
"\n",
" \n",
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
" root._bokeh_timeout = Date.now() + 5000;\n",
" root._bokeh_failed_load = false;\n",
" }\n",
"\n",
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
" \"<div style='background-color: #fdd'>\\n\"+\n",
" \"<p>\\n\"+\n",
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
" \"</p>\\n\"+\n",
" \"<ul>\\n\"+\n",
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
" \"</ul>\\n\"+\n",
" \"<code>\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"</code>\\n\"+\n",
" \"</div>\"}};\n",
"\n",
" function display_loaded() {\n",
" var el = document.getElementById(\"3b5c2006-05d2-4799-a92c-088336212af5\");\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS is loading...\";\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(display_loaded, 100)\n",
" }\n",
" }\n",
"\n",
"\n",
" function run_callbacks() {\n",
" try {\n",
" root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
" }\n",
" finally {\n",
" delete root._bokeh_onload_callbacks\n",
" }\n",
" console.info(\"Bokeh: all callbacks have finished\");\n",
" }\n",
"\n",
" function load_libs(js_urls, callback) {\n",
" root._bokeh_onload_callbacks.push(callback);\n",
" if (root._bokeh_is_loading > 0) {\n",
" console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
" return null;\n",
" }\n",
" if (js_urls == null || js_urls.length === 0) {\n",
" run_callbacks();\n",
" return null;\n",
" }\n",
" console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
" root._bokeh_is_loading = js_urls.length;\n",
" for (var i = 0; i < js_urls.length; i++) {\n",
" var url = js_urls[i];\n",
" var s = document.createElement('script');\n",
" s.src = url;\n",
" s.async = false;\n",
" s.onreadystatechange = s.onload = function() {\n",
" root._bokeh_is_loading--;\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
" run_callbacks()\n",
" }\n",
" };\n",
" s.onerror = function() {\n",
" console.warn(\"failed to load library \" + url);\n",
" };\n",
" console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
" document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
" }\n",
" };var element = document.getElementById(\"3b5c2006-05d2-4799-a92c-088336212af5\");\n",
" if (element == null) {\n",
" console.log(\"Bokeh: ERROR: autoload.js configured with elementid '3b5c2006-05d2-4799-a92c-088336212af5' but no matching script tag was found. \")\n",
" return false;\n",
" }\n",
"\n",
" var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.13.min.js\"];\n",
"\n",
" var inline_js = [\n",
" function(Bokeh) {\n",
" Bokeh.set_log_level(\"info\");\n",
" },\n",
" \n",
" function(Bokeh) {\n",
" \n",
" },\n",
" function(Bokeh) {\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n",
" }\n",
" ];\n",
"\n",
" function run_inline_js() {\n",
" \n",
" if ((root.Bokeh !== undefined) || (force === true)) {\n",
" for (var i = 0; i < inline_js.length; i++) {\n",
" inline_js[i].call(root, root.Bokeh);\n",
" }if (force === true) {\n",
" display_loaded();\n",
" }} else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(run_inline_js, 100);\n",
" } else if (!root._bokeh_failed_load) {\n",
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" root._bokeh_failed_load = true;\n",
" } else if (force !== true) {\n",
" var cell = $(document.getElementById(\"3b5c2006-05d2-4799-a92c-088336212af5\")).parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n",
"\n",
" }\n",
"\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
" run_inline_js();\n",
" } else {\n",
" load_libs(js_urls, function() {\n",
" console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
" run_inline_js();\n",
" });\n",
" }\n",
"}(window));"
],
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"3b5c2006-05d2-4799-a92c-088336212af5\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n }\n finally {\n delete root._bokeh_onload_callbacks\n }\n console.info(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(js_urls, callback) {\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = js_urls.length;\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var s = document.createElement('script');\n s.src = url;\n s.async = false;\n s.onreadystatechange = s.onload = function() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: all BokehJS libraries loaded\");\n run_callbacks()\n }\n };\n s.onerror = function() {\n console.warn(\"failed to load library \" + url);\n };\n console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.getElementsByTagName(\"head\")[0].appendChild(s);\n }\n };var element = document.getElementById(\"3b5c2006-05d2-4799-a92c-088336212af5\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '3b5c2006-05d2-4799-a92c-088336212af5' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.13.min.js\"];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n }\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"3b5c2006-05d2-4799-a92c-088336212af5\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(js_urls, function() {\n console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
"<div class=\"bk-root\">\n",
" <div class=\"bk-plotdiv\" id=\"b87debd3-e2f3-4e97-8a57-efc164a8be3d\"></div>\n",
"</div>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"d8a68a96-35f7-43d7-b727-ccbc77ce2830\":{\"roots\":{\"references\":[{\"attributes\":{\"data_source\":{\"id\":\"46f6c92d-a3ab-4ec9-b146-e2b10afd15d6\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"2b5cd973-800d-4b68-a365-be900256dafd\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"a83f01e0-9c0b-4ea1-a8b4-b2186a8354f1\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"552928ec-cdbd-4d9d-8974-2e1a317b3e79\",\"type\":\"CDSView\"}},\"id\":\"23c3bae0-ef66-4b05-be44-fecf625d2b59\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"below\":[{\"id\":\"8fdfe3fe-2c8d-4537-95fc-9b8a57e0fbd4\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"fd1b69ae-858a-455e-be8c-d970730b03d7\",\"type\":\"LinearAxis\"}],\"renderers\":[{\"id\":\"8fdfe3fe-2c8d-4537-95fc-9b8a57e0fbd4\",\"type\":\"LinearAxis\"},{\"id\":\"d3a97af5-a92b-4203-bcdb-040c6e31a3e2\",\"type\":\"Grid\"},{\"id\":\"fd1b69ae-858a-455e-be8c-d970730b03d7\",\"type\":\"LinearAxis\"},{\"id\":\"cc3e900d-0416-4838-a3cd-9fd193ab392f\",\"type\":\"Grid\"},{\"id\":\"4f4f4d79-28f2-4a84-af31-d05135742479\",\"type\":\"BoxAnnotation\"},{\"id\":\"8dd170b5-195b-4604-b687-3d5c70b7d7a8\",\"type\":\"Legend\"},{\"id\":\"23c3bae0-ef66-4b05-be44-fecf625d2b59\",\"type\":\"GlyphRenderer\"},{\"id\":\"3d8b930f-e654-45db-b98a-99d4efc1b5a7\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"ee37c854-6e03-4b6a-a20a-9017798dcb04\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"66df0f34-ee6f-44d4-b68d-04af7bbd4ee1\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"74464549-5124-4fe5-94da-bf544ed4fd12\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"5a0066ca-62d3-4805-bc4f-ad0e7ef5f3ea\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"15e9c26c-8ffe-45ec-9d3b-3bc9a8563543\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"8a0c2b62-1f4d-4e60-b3e7-45e70c68b0de\",\"type\":\"LinearScale\"}},\"id\":\"e27e52b1-328a-4e52-9e24-9afdd8d143b2\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"callback\":null},\"id\":\"74464549-5124-4fe5-94da-bf544ed4fd12\",\"type\":\"DataRange1d\"},{\"attributes\":{\"plot\":{\"id\":\"e27e52b1-328a-4e52-9e24-9afdd8d143b2\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"d6d30ad9-fbfe-45be-b5aa-f34b010ddbd7\",\"type\":\"BasicTicker\"}},\"id\":\"d3a97af5-a92b-4203-bcdb-040c6e31a3e2\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"043c2575-7dac-45eb-b328-a823adedae56\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"e27e52b1-328a-4e52-9e24-9afdd8d143b2\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"80e73177-37eb-4ca9-af7a-bdb905691a15\",\"type\":\"BasicTicker\"}},\"id\":\"fd1b69ae-858a-455e-be8c-d970730b03d7\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"d6d30ad9-fbfe-45be-b5aa-f34b010ddbd7\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"e27e52b1-328a-4e52-9e24-9afdd8d143b2\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"80e73177-37eb-4ca9-af7a-bdb905691a15\",\"type\":\"BasicTicker\"}},\"id\":\"cc3e900d-0416-4838-a3cd-9fd193ab392f\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"80e73177-37eb-4ca9-af7a-bdb905691a15\",\"type\":\"BasicTicker\"},{\"attributes\":{\"formatter\":{\"id\":\"0625deed-9a76-4360-ba0d-b02159b3877a\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"e27e52b1-328a-4e52-9e24-9afdd8d143b2\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"d6d30ad9-fbfe-45be-b5aa-f34b010ddbd7\",\"type\":\"BasicTicker\"}},\"id\":\"8fdfe3fe-2c8d-4537-95fc-9b8a57e0fbd4\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[0.0,1.0,1.25,1.5,1.75,2.0,2.5,3.0,3.5,4.0,4.5],\"y\":[63.72,59.07,57.35,55.92,54.16,52.11,47.9,43.16,37.82,32.72,27.59]}},\"id\":\"9484cf01-695f-41cf-a0c4-e2a2d0c4233b\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"source\":{\"id\":\"46f6c92d-a3ab-4ec9-b146-e2b10afd15d6\",\"type\":\"ColumnDataSource\"}},\"id\":\"552928ec-cdbd-4d9d-8974-2e1a317b3e79\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"37b40904-0b97-4721-99ff-d56d5cd3eedc\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"043c2575-7dac-45eb-b328-a823adedae56\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"line_width\":2,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"a83f01e0-9c0b-4ea1-a8b4-b2186a8354f1\",\"type\":\"Line\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"4f4f4d79-28f2-4a84-af31-d05135742479\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"9ac7de16-9095-40f6-9941-ccddceaa8146\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"data_source\":{\"id\":\"9484cf01-695f-41cf-a0c4-e2a2d0c4233b\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"e46b5926-edec-4036-af1e-f22a4236735c\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"13e4b6ed-f14a-4d44-b561-21a571d6fdb3\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"ad06f055-83e6-4684-accc-611bad367f88\",\"type\":\"CDSView\"}},\"id\":\"3d8b930f-e654-45db-b98a-99d4efc1b5a7\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"aac290cc-7046-40cc-bb4b-9aae8eb67c89\",\"type\":\"SaveTool\"},{\"attributes\":{\"plot\":null,\"text\":\"Precision and recall over subvalue\"},\"id\":\"ee37c854-6e03-4b6a-a20a-9017798dcb04\",\"type\":\"Title\"},{\"attributes\":{\"label\":{\"value\":\"precision\"},\"renderers\":[{\"id\":\"23c3bae0-ef66-4b05-be44-fecf625d2b59\",\"type\":\"GlyphRenderer\"}]},\"id\":\"8a3b3070-7b83-41b8-a84c-2a6d861f597f\",\"type\":\"LegendItem\"},{\"attributes\":{\"overlay\":{\"id\":\"4f4f4d79-28f2-4a84-af31-d05135742479\",\"type\":\"BoxAnnotation\"}},\"id\":\"afa705f9-8022-4c3b-b545-e2e1e9c0c342\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"aa08f49c-f9be-498a-b06b-2a8bdcd185db\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"a336faf1-7916-4948-8d6f-6399ddb00ff4\",\"type\":\"ResetTool\"},{\"attributes\":{\"source\":{\"id\":\"9484cf01-695f-41cf-a0c4-e2a2d0c4233b\",\"type\":\"ColumnDataSource\"}},\"id\":\"ad06f055-83e6-4684-accc-611bad367f88\",\"type\":\"CDSView\"},{\"attributes\":{\"line_color\":\"red\",\"line_width\":2,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"e46b5926-edec-4036-af1e-f22a4236735c\",\"type\":\"Line\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"line_width\":2,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"13e4b6ed-f14a-4d44-b561-21a571d6fdb3\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"0625deed-9a76-4360-ba0d-b02159b3877a\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"8a0c2b62-1f4d-4e60-b3e7-45e70c68b0de\",\"type\":\"LinearScale\"},{\"attributes\":{\"items\":[{\"id\":\"8a3b3070-7b83-41b8-a84c-2a6d861f597f\",\"type\":\"LegendItem\"},{\"id\":\"c19749b7-445b-426d-a324-33ae0a3491f1\",\"type\":\"LegendItem\"}],\"plot\":{\"id\":\"e27e52b1-328a-4e52-9e24-9afdd8d143b2\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"8dd170b5-195b-4604-b687-3d5c70b7d7a8\",\"type\":\"Legend\"},{\"attributes\":{\"label\":{\"value\":\"recall\"},\"renderers\":[{\"id\":\"3d8b930f-e654-45db-b98a-99d4efc1b5a7\",\"type\":\"GlyphRenderer\"}]},\"id\":\"c19749b7-445b-426d-a324-33ae0a3491f1\",\"type\":\"LegendItem\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"37b40904-0b97-4721-99ff-d56d5cd3eedc\",\"type\":\"PanTool\"},{\"id\":\"9ac7de16-9095-40f6-9941-ccddceaa8146\",\"type\":\"WheelZoomTool\"},{\"id\":\"afa705f9-8022-4c3b-b545-e2e1e9c0c342\",\"type\":\"BoxZoomTool\"},{\"id\":\"aac290cc-7046-40cc-bb4b-9aae8eb67c89\",\"type\":\"SaveTool\"},{\"id\":\"a336faf1-7916-4948-8d6f-6399ddb00ff4\",\"type\":\"ResetTool\"},{\"id\":\"aa08f49c-f9be-498a-b06b-2a8bdcd185db\",\"type\":\"HelpTool\"}]},\"id\":\"66df0f34-ee6f-44d4-b68d-04af7bbd4ee1\",\"type\":\"Toolbar\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[0.0,1.0,1.25,1.5,1.75,2.0,2.5,3.0,3.5,4.0,4.5],\"y\":[70.23,75.39,76.33128758434991,77.30616236686618,78.44626239927828,79.23,80.08497663889726,80.54,80.66917325855214,80.58328176701993,80.32030154827109]}},\"id\":\"46f6c92d-a3ab-4ec9-b146-e2b10afd15d6\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"line_color\":\"blue\",\"line_width\":2,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"2b5cd973-800d-4b68-a365-be900256dafd\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"5a0066ca-62d3-4805-bc4f-ad0e7ef5f3ea\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null},\"id\":\"15e9c26c-8ffe-45ec-9d3b-3bc9a8563543\",\"type\":\"DataRange1d\"}],\"root_ids\":[\"e27e52b1-328a-4e52-9e24-9afdd8d143b2\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.13\"}};\n",
" var render_items = [{\"docid\":\"d8a68a96-35f7-43d7-b727-ccbc77ce2830\",\"elementid\":\"b87debd3-e2f3-4e97-8a57-efc164a8be3d\",\"modelid\":\"e27e52b1-328a-4e52-9e24-9afdd8d143b2\"}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" clearInterval(timer);\n",
" }\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\")\n",
" clearInterval(timer);\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"application/vnd.bokehjs_exec.v0+json": {
"id": "e27e52b1-328a-4e52-9e24-9afdd8d143b2"
}
},
"output_type": "display_data"
}
],
"source": [
"x, precision, recall = [],[],[]\n",
"map_xp = {}\n",
"map_xr = {}\n",
"with open('/home/NewPartion/e2e-coref/precision_recall.txt','r') as f:\n",
" for item in f.readlines():\n",
" x.append(float(item.split(' ')[0]))\n",
" precision.append(float(item.split(' ')[1]))\n",
" recall.append(float(item.split(' ')[2][:5]))\n",
"for x1,p,r in zip(x, precision, recall):\n",
" map_xp.setdefault(x1, p)\n",
" map_xr.setdefault(x1,r)\n",
"\n",
"p = [map_xp[item] for item in sorted(map_xp)]\n",
"r = [map_xr[item] for item in sorted(map_xr)]\n",
"x = sorted(x)\n",
"print(x)\n",
"\n",
"picture = figure(title='Precision and recall over subvalue')\n",
"picture.line(x, p,legend='precision',color='blue', line_width=2)\n",
"picture.line(x, r, legend='recall',color='red', line_width=2)\n",
"output_notebook()\n",
"show(picture)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"ExecuteTime": {
"end_time": "2018-09-12T08:28:10.539537Z",
"start_time": "2018-09-12T08:28:10.535753Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[75.39, 79.23, 80.54]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"precision\n"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {
"ExecuteTime": {
"end_time": "2018-09-12T08:22:35.589140Z",
"start_time": "2018-09-12T08:22:35.585592Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['59.07', '52.11', '43.16']"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"recall"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2018-09-12T06:42:23.135416Z",
"start_time": "2018-09-12T06:42:23.122020Z"
}
},
"outputs": [],
"source": [
"def sub_certain_value_from_matrix(matrix, value):\n",
" new_matrixes = []\n",
" for i, item1 in enumerate(matrix):\n",
" new_matrix = item1\n",
" for j, item2 in enumerate(item1):\n",
" for k, item3 in enumerate(item2):\n",
" if k > 0:\n",
" item3 = item3-value\n",
" new_matrix[j, k]=item3\n",
" new_matrixes.append(new_matrix)\n",
" return np.array(new_matrixes)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"util.set_gpus()\n",
"\n",
"if len(sys.argv) > 1:\n",
" name = sys.argv[1]\n",
"else:\n",
" name = os.environ[\"EXP\"]\n",
"\n",
"config = util.get_config(\"experiments.conf\")[name]\n",
"config[\"log_dir\"] = util.mkdirs(os.path.join(config[\"log_root\"], name))\n",
"config[\"combination_ratio\"] = 1\n",
"\n",
"util.print_config(config)\n",
"#model = cm.CorefModel(config)\n",
"\n",
"model = cmm.CorefMermaidModel(config)\n",
"\n",
"saver = tf.train.Saver()\n",
"log_dir = config[\"log_dir\"]\n",
"writer = tf.summary.FileWriter(log_dir, flush_secs=20)\n",
"evaluated_checkpoints = set()\n",
"max_f1 = 0\n",
"checkpoint_pattern = re.compile(\".*model.ckpt-([0-9]*)\\Z\")\n",
"\n",
"ckpt = tf.train.get_checkpoint_state(log_dir)\n",
"if ckpt and ckpt.model_checkpoint_path and ckpt.model_checkpoint_path not in evaluated_checkpoints:\n",
"print \"Evaluating {}\".format(ckpt.model_checkpoint_path)\n",
"\n",
"# Move it to a temporary location to avoid being deleted by the training supervisor.\n",
"tmp_checkpoint_path = os.path.join(log_dir, \"model.tmp.ckpt\")\n",
"copy_checkpoint(ckpt.model_checkpoint_path, tmp_checkpoint_path)\n",
"\n",
"global_step = int(checkpoint_pattern.match(ckpt.model_checkpoint_path).group(1))\n",
"saver.restore(session, ckpt.model_checkpoint_path)\n",
"\n",
"eval_summary, f1 = model.evaluate(session)\n",
"\n",
"if f1 > max_f1:\n",
" max_f1 = f1\n",
" copy_checkpoint(tmp_checkpoint_path, os.path.join(log_dir, \"model.max.ckpt\"))\n",
"\n",
"print \"Current max F1: {:.2f}\".format(max_f1)\n",
"\n",
"writer.add_summary(eval_summary, global_step)\n",
"print \"Evaluation written to {} at step {}\".format(log_dir, global_step)\n",
"\n",
"evaluated_checkpoints.add(ckpt.model_checkpoint_path)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment