Skip to content

Instantly share code, notes, and snippets.

@dvas0004
Created March 15, 2019 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvas0004/88bb7c4ba3e20b34d6fcc111ff9478e0 to your computer and use it in GitHub Desktop.
Save dvas0004/88bb7c4ba3e20b34d6fcc111ff9478e0 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exploring Gaussian Process vs Linear Regression"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: bokeh in /usr/local/lib/python3.6/dist-packages (1.0.4)\n",
"Requirement already satisfied: six>=1.5.2 in /home/snuc/.local/lib/python3.6/site-packages (from bokeh) (1.12.0)\n",
"Requirement already satisfied: PyYAML>=3.10 in /usr/lib/python3/dist-packages (from bokeh) (3.12)\n",
"Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from bokeh) (2.8.0)\n",
"Requirement already satisfied: Jinja2>=2.7 in /usr/lib/python3/dist-packages (from bokeh) (2.10)\n",
"Requirement already satisfied: numpy>=1.7.1 in /home/snuc/.local/lib/python3.6/site-packages (from bokeh) (1.16.2)\n",
"Requirement already satisfied: pillow>=4.0 in /usr/lib/python3/dist-packages (from bokeh) (5.1.0)\n",
"Requirement already satisfied: packaging>=16.8 in /usr/local/lib/python3.6/dist-packages (from bokeh) (19.0)\n",
"Requirement already satisfied: tornado>=4.3 in /usr/local/lib/python3.6/dist-packages (from bokeh) (6.0.1)\n",
"Requirement already satisfied: pyparsing>=2.0.2 in /usr/lib/python3/dist-packages (from packaging>=16.8->bokeh) (2.2.0)\n",
"Requirement already satisfied: scikit-learn in /home/snuc/.local/lib/python3.6/site-packages (0.20.3)\n",
"Requirement already satisfied: numpy>=1.8.2 in /home/snuc/.local/lib/python3.6/site-packages (from scikit-learn) (1.16.2)\n",
"Requirement already satisfied: scipy>=0.13.3 in /home/snuc/.local/lib/python3.6/site-packages (from scikit-learn) (1.2.1)\n"
]
}
],
"source": [
"!pip install bokeh\n",
"!pip install scikit-learn"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"from math import sin\n",
"\n",
"from bokeh.plotting import figure, show\n",
"from bokeh.models import Band, ColumnDataSource\n",
"from bokeh.io import output_notebook\n",
"\n",
"from sklearn import linear_model\n",
"from sklearn.gaussian_process import GaussianProcessRegressor"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Define our data generating functions\n",
"One is to be linear, the other non-linear"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"def func_non_linear(x):\n",
" return sin(5*x) + (0.5*x)\n",
"\n",
"def func_linear(x):\n",
" return 3*x"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Define the experiment framework\n",
"Given a data generating function:\n",
"* sample a random set of X co-ordinates\n",
"* find their equivalent Y co-ordinates by running the data generating function\n",
"* fit a linear regression model\n",
"* predict a set of test values from the linear regression model\n",
"* do the same for a Gaussian Process, with default settings of RBF kernel\n",
"* plot using bokeh"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"def run_experiment(func):\n",
" # create random sample of X\n",
" sample_x = np.random.uniform(0, 10 ,50)\n",
" sample_y = []\n",
"\n",
" # calculate corresponding Y\n",
" for x in sample_x:\n",
" sample_y.append(func(x))\n",
"\n",
" sample_x = np.asarray(sample_x).reshape(-1, 1)\n",
" sample_y = np.asarray(sample_y).reshape(-1, 1)\n",
"\n",
" # fit and predict using Linear Regression\n",
" regr = linear_model.LinearRegression()\n",
" regr.fit(sample_x, sample_y)\n",
"\n",
" x_test = np.linspace(0,10,50)\n",
" y_pred = regr.predict(x_test.reshape(-1,1))\n",
"\n",
" # Do the same using Gaussian Process\n",
" gpr = GaussianProcessRegressor(random_state=0)\n",
" gpr.fit(sample_x, sample_y)\n",
" y_pred_gaussian = gpr.predict(x_test.reshape(-1,1))\n",
"\n",
" # Plot\n",
" p = figure(plot_width=400, plot_height=400)\n",
" p.circle(sample_x[:,0], sample_y[:,0])\n",
" p.line(x_test, y_pred[:,0], color=\"red\")\n",
" p.line(x_test, y_pred_gaussian[:,0], color=\"green\")\n",
" show(p)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"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=\"1001\">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 != null && id in Bokeh.index) {\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 id = msg.content.text.trim();\n",
" if (id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\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[toinsert.length - 1].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[toinsert.length - 1].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[toinsert.length - 1]);\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(\"1001\");\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(\"1001\");\n",
" if (element == null) {\n",
" console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1001' but no matching script tag was found. \")\n",
" return false;\n",
" }\n",
"\n",
" var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.4.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-1.0.4.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.css\");\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css\");\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.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(\"1001\")).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(\"1001\");\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(\"1001\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1001' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.4.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-1.0.4.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.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(\"1001\")).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"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"(50, 1)\n",
"(50, 1)\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"28a6db58-cbd7-455e-81af-e9ae66b53087\" data-root-id=\"1002\"></div>\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"db584e5d-96a1-4b57-9be8-d9765183422f\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1011\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"1016\",\"type\":\"LinearAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"1011\",\"type\":\"LinearAxis\"},{\"id\":\"1015\",\"type\":\"Grid\"},{\"id\":\"1016\",\"type\":\"LinearAxis\"},{\"id\":\"1020\",\"type\":\"Grid\"},{\"id\":\"1029\",\"type\":\"BoxAnnotation\"},{\"id\":\"1039\",\"type\":\"GlyphRenderer\"},{\"id\":\"1044\",\"type\":\"GlyphRenderer\"},{\"id\":\"1049\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"1051\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"1027\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"1003\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"1007\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"1005\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"1009\",\"type\":\"LinearScale\"}},\"id\":\"1002\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1012\",\"type\":\"BasicTicker\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1038\",\"type\":\"Circle\"},{\"attributes\":{\"line_color\":\"red\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1042\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1057\",\"type\":\"Selection\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1043\",\"type\":\"Line\"},{\"attributes\":{\"plot\":{\"id\":\"1002\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1012\",\"type\":\"BasicTicker\"}},\"id\":\"1015\",\"type\":\"Grid\"},{\"attributes\":{\"data_source\":{\"id\":\"1041\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"1042\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1043\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"1045\",\"type\":\"CDSView\"}},\"id\":\"1044\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"formatter\":{\"id\":\"1055\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"1002\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1017\",\"type\":\"BasicTicker\"}},\"id\":\"1016\",\"type\":\"LinearAxis\"},{\"attributes\":{\"source\":{\"id\":\"1041\",\"type\":\"ColumnDataSource\"}},\"id\":\"1045\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1017\",\"type\":\"BasicTicker\"},{\"attributes\":{\"callback\":null,\"data\":{\"x\":{\"__ndarray__\":\"AAAAAAAAAACIxvrQWB/KP4jG+tBYH9o/5hS8nIKX4z+IxvrQWB/qPxW8nIKXU/A/5hS8nIKX8z+3bdu2bdv2P4jG+tBYH/o/WR8a60Nj/T8VvJyCl1MAQH5orA+N9QFA5hS8nIKXA0BOwcspeDkFQLdt27Zt2wZAIBrrQ2N9CECIxvrQWB8KQPByCl5OwQtAWR8a60NjDUDCyyl4OQUPQBW8nIKXUxBASZIkSZIkEUB+aKwPjfURQLI+NNaHxhJA5hS8nIKXE0Aa60NjfWgUQE7Byyl4ORVAg5dT8HIKFkC3bdu2bdsWQOtDY31orBdAIBrrQ2N9GEBU8HIKXk4ZQIjG+tBYHxpAvJyCl1PwGkDwcgpeTsEbQCVJkiRJkhxAWR8a60NjHUCN9aGxPjQeQMLLKXg5BR9A9qGxPjTWH0AVvJyCl1MgQC+n4OUUvCBASZIkSZIkIUBjfWisD40hQH5orA+N9SFAmFPwcgpeIkCyPjTWh8YiQMwpeDkFLyNA5hS8nIKXI0AAAAAAAAAkQA==\",\"dtype\":\"float64\",\"shape\":[50]},\"y\":{\"__ndarray__\":\"AABfrh3OgD8AMNZVTIzuPwCgVDytjvE/AMAjULac2D8AgJWZpb7ZvwAAPBiemNq/AACzRmb33D8AADhoNIz3PwAA4+MIS/w/AADrsgaD8j8AAJB/DFbUPwAAsCJgAsM/AAC0dMER7T8AAEBMBYX/PwAAmF1WVwNAAADMYDS//j8AADhC7NfwPwAA8JkTluc/AABITfz39T8AABhwGJwDQAAABLDrUghAAAAoMKNoBUAAAFgTu9j8PwAASO+1nvU/AACkGjKX/T8AAG4jU1sHQAAA9sH5Gg1AAABAnfFVC0AAAPGq6IMEQAAAiDX72/8/AICut067AkAAAGtp1wYLQAAA2EIr1xBAACAxSRmQEEAAoG6nKqsKQAAQP/RQPwVAADC1DB/QBkAA+NJ/zqYOQABM0Q0bCBNAAPLHjKtgE0AA9ZcacWwQQIClnHWOwQpAwFShWAcSC0BwpuVSKiIRQDB/DcdoIRVAitwrEbMaFkB+VbnvaoMTQE8GOVCUNxBAK4We/juCD0AR04pzJvASQA==\",\"dtype\":\"float64\",\"shape\":[50]}},\"selected\":{\"id\":\"1061\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"1062\",\"type\":\"UnionRenderers\"}},\"id\":\"1046\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"1002\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1017\",\"type\":\"BasicTicker\"}},\"id\":\"1020\",\"type\":\"Grid\"},{\"attributes\":{\"line_color\":\"green\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1047\",\"type\":\"Line\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1021\",\"type\":\"PanTool\"},{\"id\":\"1022\",\"type\":\"WheelZoomTool\"},{\"id\":\"1023\",\"type\":\"BoxZoomTool\"},{\"id\":\"1024\",\"type\":\"SaveTool\"},{\"id\":\"1025\",\"type\":\"ResetTool\"},{\"id\":\"1026\",\"type\":\"HelpTool\"}]},\"id\":\"1027\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1022\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1048\",\"type\":\"Line\"},{\"attributes\":{\"data_source\":{\"id\":\"1046\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"1047\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1048\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"1050\",\"type\":\"CDSView\"}},\"id\":\"1049\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1021\",\"type\":\"PanTool\"},{\"attributes\":{\"source\":{\"id\":\"1046\",\"type\":\"ColumnDataSource\"}},\"id\":\"1050\",\"type\":\"CDSView\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1037\",\"type\":\"Circle\"},{\"attributes\":{\"overlay\":{\"id\":\"1029\",\"type\":\"BoxAnnotation\"}},\"id\":\"1023\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"1051\",\"type\":\"Title\"},{\"attributes\":{\"callback\":null},\"id\":\"1003\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1024\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1053\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1025\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1007\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1055\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1026\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1058\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"formatter\":{\"id\":\"1053\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"1002\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1012\",\"type\":\"BasicTicker\"}},\"id\":\"1011\",\"type\":\"LinearAxis\"},{\"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\":\"1029\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"1059\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1009\",\"type\":\"LinearScale\"},{\"attributes\":{\"data_source\":{\"id\":\"1036\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"1037\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1038\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"1040\",\"type\":\"CDSView\"}},\"id\":\"1039\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1060\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"callback\":null},\"id\":\"1005\",\"type\":\"DataRange1d\"},{\"attributes\":{\"callback\":null,\"data\":{\"x\":{\"__ndarray__\":\"ICYye4y9tz8A3gksh1UaQKAT1y3EqRFAfK9u0f/cIUCKrvSyRgQfQEK7N0h20ANANFGENIPhDUA3CyxSmXogQHvnb/tX1SNA7hP9nkkI4D/OJlFvltDgPwyqF2gNMiNAq4kPV8xBGkCOwT1VSDgjQAo3i1oHPxxARJk7RTzBBEAl/VGwEP39P9MEcApcNyBAaRr3E5zsFkCukurwqc0gQP6PXQ7GvxpA5SrIkwZAIEAnr0nzUO8AQFKULVOUyQJAW7JtVDyWI0CuXw0YOib3P4UYNFJ8rxNAVh1PHl0tI0AcBM6dj7gFQAbmqAoiighAKkhqUmJL9D84O4FhMf/JPypriQMw8B5AyO8K2GD/wz/Url3OFOsiQDx3phP8iwZAHOxMp/cxIkBOGqZmUrQWQMKNU7EWOxpAx32+Yj75IkASD+AYHrkIQAaKjwpNmR1A8eYxcDpT8T8FSlsmoB0WQL0p7gAFbxlAyH/tKaQpHkAkZKjJEGgjQGqgWW8H5/8/LxLpRDCGC0BNhpiFi7ESQA==\",\"dtype\":\"float64\",\"shape\":[50]},\"y\":{\"__ndarray__\":\"7P4xflGX3z8UwcfjUSgRQKXvHso09gBAlJQd1JxdFEBgdxJZQgUTQM2hzsJd6fA/Z8u5YXIc+z8FmMkwWyoOQIHulonUTxFAby5nOpEJ6z8G0IHfAiboP2qT6V3BJhBAhePrveoSEUD9G4ZLCQYQQLeIIvGsygZATLfZFqAQ+z+PlEin/LHvPzLG+O8NZhFA++k0jRbzA0CA3Rmwcj8KQLBK/TkX+hBAaiMrffIaEUCIoK20ZifCP7ozIj4DLNw/TizqjAR4D0Ao7QBlMZn4P9DBPm/kVv8/KExQ4klBEED9/J5SvaEBQMbPu4sTVv4/DhUquxct5j/b2PATA3HuP+xpypDmxhJAmFRkJekH6T+j5ooH/zsSQOjo5qHhQwNAzIrJ18svFkBMF9TKWNsFQKUYGgl/CRFAZb2werzAEUD3aOBtV8b8P0DEwhYMcQhAgCUY0Fd1zL9C7J8fqdMKQDtcfJtbXwxAP6ZV2EUyDkBTt6eKpPAOQDi/9Lbwo94/Uj0TPR4k5z/7TQFFvbD1Pw==\",\"dtype\":\"float64\",\"shape\":[50]}},\"selected\":{\"id\":\"1057\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"1058\",\"type\":\"UnionRenderers\"}},\"id\":\"1036\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1061\",\"type\":\"Selection\"},{\"attributes\":{\"source\":{\"id\":\"1036\",\"type\":\"ColumnDataSource\"}},\"id\":\"1040\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1062\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"callback\":null,\"data\":{\"x\":{\"__ndarray__\":\"AAAAAAAAAACIxvrQWB/KP4jG+tBYH9o/5hS8nIKX4z+IxvrQWB/qPxW8nIKXU/A/5hS8nIKX8z+3bdu2bdv2P4jG+tBYH/o/WR8a60Nj/T8VvJyCl1MAQH5orA+N9QFA5hS8nIKXA0BOwcspeDkFQLdt27Zt2wZAIBrrQ2N9CECIxvrQWB8KQPByCl5OwQtAWR8a60NjDUDCyyl4OQUPQBW8nIKXUxBASZIkSZIkEUB+aKwPjfURQLI+NNaHxhJA5hS8nIKXE0Aa60NjfWgUQE7Byyl4ORVAg5dT8HIKFkC3bdu2bdsWQOtDY31orBdAIBrrQ2N9GEBU8HIKXk4ZQIjG+tBYHxpAvJyCl1PwGkDwcgpeTsEbQCVJkiRJkhxAWR8a60NjHUCN9aGxPjQeQMLLKXg5BR9A9qGxPjTWH0AVvJyCl1MgQC+n4OUUvCBASZIkSZIkIUBjfWisD40hQH5orA+N9SFAmFPwcgpeIkCyPjTWh8YiQMwpeDkFLyNA5hS8nIKXI0AAAAAAAAAkQA==\",\"dtype\":\"float64\",\"shape\":[50]},\"y\":{\"__ndarray__\":\"EOub/tjK0j/UxRe9eKrYP5mgk3sYit4/r70HHdw04j8Rq0X8qyTlP3SYg9t7FOg/1oXBuksE6z84c/+ZG/TtP02wnrz1cfA//qY9rN3p8T+wndybxWHzP2GUe4ut2fQ/Eosae5VR9j/Cgblqfcn3P3R4WFplQfk/JW/3SU25+j/WZZY5NTH8P4dcNSkdqf0/OFPUGAUh/z/1pDmEdkwAQE4gCXxqCAFAppvYc17EAUD/FqhrUoACQFeSd2NGPANAsA1HWzr4A0AIiRZTLrQEQGAE5koicAVAun+1QhYsBkAS+4Q6CugGQGp2VDL+owdAw/EjKvJfCEAcbfMh5hsJQHTowhna1wlAzGOSEc6TCkAl32EJwk8LQH5aMQG2CwxA1tUA+anHDEAvUdDwnYMNQIjMn+iRPw5A4Edv4IX7DkA5wz7YebcPQEgfB+i2ORBA9Nzu47CXEEChmtbfqvUQQE5YvtukUxFA+hWm156xEUCm043TmA8SQFKRdc+SbRJA/05dy4zLEkCrDEXHhikTQA==\",\"dtype\":\"float64\",\"shape\":[50]}},\"selected\":{\"id\":\"1059\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"1060\",\"type\":\"UnionRenderers\"}},\"id\":\"1041\",\"type\":\"ColumnDataSource\"}],\"root_ids\":[\"1002\"]},\"title\":\"Bokeh Application\",\"version\":\"1.0.4\"}};\n",
" var render_items = [{\"docid\":\"db584e5d-96a1-4b57-9be8-d9765183422f\",\"roots\":{\"1002\":\"28a6db58-cbd7-455e-81af-e9ae66b53087\"}}];\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": "1002"
}
},
"output_type": "display_data"
}
],
"source": [
"output_notebook()\n",
"run_experiment(func_non_linear)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Bonus : Standard Deviation\n",
"Gaussian Proccess also allows you to view the standard deviation of a prediction at a certain point. This is useful in visualizing the amount of \"uncertainty\". The higher the standard deviation, the lower the certainty. In the below example, the standard dev was very small, so I artificially inflated the standard dev values for easier visualization on the plot by multiplying the real values by a factor of 100"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"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=\"1276\">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 != null && id in Bokeh.index) {\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 id = msg.content.text.trim();\n",
" if (id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\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[toinsert.length - 1].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[toinsert.length - 1].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[toinsert.length - 1]);\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(\"1276\");\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(\"1276\");\n",
" if (element == null) {\n",
" console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1276' but no matching script tag was found. \")\n",
" return false;\n",
" }\n",
"\n",
" var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.4.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-1.0.4.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.css\");\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css\");\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.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(\"1276\")).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(\"1276\");\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(\"1276\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1276' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.4.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-1.0.4.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.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(\"1276\")).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"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/snuc/.local/lib/python3.6/site-packages/sklearn/gaussian_process/gpr.py:357: UserWarning: Predicted variances smaller than 0. Setting those variances to 0.\n",
" warnings.warn(\"Predicted variances smaller than 0. \"\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"44cd56a5-34cb-4b70-84f4-afc9ba623fcf\" data-root-id=\"1277\"></div>\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"d905902a-2bd8-463a-ac1a-dc56b2bf2267\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1286\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"1291\",\"type\":\"LinearAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"1286\",\"type\":\"LinearAxis\"},{\"id\":\"1290\",\"type\":\"Grid\"},{\"id\":\"1291\",\"type\":\"LinearAxis\"},{\"id\":\"1295\",\"type\":\"Grid\"},{\"id\":\"1304\",\"type\":\"BoxAnnotation\"},{\"id\":\"1314\",\"type\":\"GlyphRenderer\"},{\"id\":\"1317\",\"type\":\"Band\"}],\"title\":{\"id\":\"1343\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"1302\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"1278\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"1282\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"1280\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"1284\",\"type\":\"LinearScale\"}},\"id\":\"1277\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1349\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1287\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1284\",\"type\":\"LinearScale\"},{\"attributes\":{\"formatter\":{\"id\":\"1345\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"1277\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1287\",\"type\":\"BasicTicker\"}},\"id\":\"1286\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1351\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1350\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1282\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null},\"id\":\"1280\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1352\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1345\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1296\",\"type\":\"PanTool\"},{\"id\":\"1297\",\"type\":\"WheelZoomTool\"},{\"id\":\"1298\",\"type\":\"BoxZoomTool\"},{\"id\":\"1299\",\"type\":\"SaveTool\"},{\"id\":\"1300\",\"type\":\"ResetTool\"},{\"id\":\"1301\",\"type\":\"HelpTool\"}]},\"id\":\"1302\",\"type\":\"Toolbar\"},{\"attributes\":{\"callback\":null,\"data\":{\"x\":{\"__ndarray__\":\"DI9lXBO5EECsRIWGsjP4P+yKVBA5oQdArMpfRvIAC0DMoYWQ1WMMQIg7pPNPjtY/A6/aCiTwG0DqjhnhBfEQQJj3XdbFORBAiTSmK03r+T9NW5QmvloPQKO8cSSp7iFAgrsSQl3aAkBra4x2aaUCQO4WvQ0y4BpAKjVYSNA2DkDo8AFRTQTkPyOkS+aJUhxARFX4A8qvBkCeEsb9h2shQH4Lr1WnmvY/QW/6Pacz9D9T4FTtIxAKQOrlFD8qvSBA0mZjsNNo/D8SHh8x4qwBQLoMBPPuBPw/XHiBv06gGUDNF0voVpwgQADo1yUbTYY/CaezMb5MFUCoBfz4lF/tP5i2F3aoUvQ/1zZRu+oYH0Dfd6CgnccRQOZANkPTpQVA0mzhK5JuB0BeLEZYkG4gQADJuU4u4xpAFSLq8zptFEDiWoVdSuYSQIL0Ca+4iAZAhbvojp6ABEAL82oussEjQBDnwPGx894/eDACKaTlxT8kPyCa2M0hQME+mj3GLfY/HdZGOiECCEBBfnS6g4AjQA==\",\"dtype\":\"float64\",\"shape\":[50]},\"y\":{\"__ndarray__\":\"QGr3k3nOB0A+UVAyym37P04kZ0u1RQJAf+OUFzGN6D9+gqYwZS3sP/TlqwMBh/I/mf85nwYVCUCkMl4tZMIGQPIoHtM6JghADiW025V6/D8txgeD1xwFQFX10zHf7hRAipJcPxRB3j+yLz69/fTXP0WldXmZuBBAaTeeICTD/j8flnvhIOnUPzzyYBkDVgZAQA4ZhxZWA0DAMK6dPX0PQNGNdmK1j/Y/+cuPt0so5T/WZ1Ihf0bxP/Pyy4G4twpAprhVizWG9j9QIZnqCiW7PyBJ61MH7vc/LizHYfhADkBlAmqETScMQI8Ueth+pq4/2rRGmmJGDUCF7JHphBLhv8bl2e/1fOY/hw0o6lI8E0CtDas4Vdv/P+A5s5ewZAFA1gggL+G0AkAkjkHmQvgOQOkfOhB6sRBAC5ukvOiLB0CexyFmldT1P+E9UbdxQQNAnbTthZ9s+D9XzGnkcLAQQL/C02716+w/RoQxFgzk6j//oM4YrNETQCgeuHAyvvQ/kpVxHL8sAUC0YaWTwQQPQA==\",\"dtype\":\"float64\",\"shape\":[50]}},\"selected\":{\"id\":\"1349\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"1350\",\"type\":\"UnionRenderers\"}},\"id\":\"1311\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"callback\":null},\"id\":\"1278\",\"type\":\"DataRange1d\"},{\"attributes\":{\"callback\":null,\"data\":{\"base\":{\"__ndarray__\":\"AAAAAAAAAACIxvrQWB/KP4jG+tBYH9o/5hS8nIKX4z+IxvrQWB/qPxW8nIKXU/A/5hS8nIKX8z+3bdu2bdv2P4jG+tBYH/o/WR8a60Nj/T8VvJyCl1MAQH5orA+N9QFA5hS8nIKXA0BOwcspeDkFQLdt27Zt2wZAIBrrQ2N9CECIxvrQWB8KQPByCl5OwQtAWR8a60NjDUDCyyl4OQUPQBW8nIKXUxBASZIkSZIkEUB+aKwPjfURQLI+NNaHxhJA5hS8nIKXE0Aa60NjfWgUQE7Byyl4ORVAg5dT8HIKFkC3bdu2bdsWQOtDY31orBdAIBrrQ2N9GEBU8HIKXk4ZQIjG+tBYHxpAvJyCl1PwGkDwcgpeTsEbQCVJkiRJkhxAWR8a60NjHUCN9aGxPjQeQMLLKXg5BR9A9qGxPjTWH0AVvJyCl1MgQC+n4OUUvCBASZIkSZIkIUBjfWisD40hQH5orA+N9SFAmFPwcgpeIkCyPjTWh8YiQMwpeDkFLyNA5hS8nIKXI0AAAAAAAAAkQA==\",\"dtype\":\"float64\",\"shape\":[50]},\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49],\"lower\":{\"__ndarray__\":\"AAAAwEt33D4qoKUR+lDqPwBgHrlliPE/AAAqGAm42D8UcW2x9iTivwAArm5Pidq/1JoGWwbQyj8AAKQ8jYz3PzH407Xj7/c/cU7LMLSF7T8AABClVFbUPwDQBPT/XmY/gILI52FC5T8AAEDxAYX/PwAALsQ1VwNAAADA5yS//j+YxSomff3sPwAAKJ35lec/AACk3gr49T8AABxDX5wDQKnLemDW3gZAAAC6KfZoBUDwl2LlQbX6P3cvK21fY/I/9rZ3vss4+j+JxaYnASYGQHfHwpkf1AtADtWjbU7lCUCxdoL01UkDQCVXrwjSMv0/AXYbZ1XaAEBCeuuLwM8IQHjBrmCuChBAdDwLfxEsD0D04EjwxrQIQHeOlo25NQNA9Iq0QNkXBUC96rWbjuAMQGJzsOYFZBJAC4B0QS3tEkCqcyUEtFYQQEcuhrzk+QlAAABWd5UQC0Ab7harBcAQQL4B4y+d4BRAAPA62cwPFkAA0EatL2QTQACwVOQhGhBAXZNct+DCDkC8gxHnIkASQA==\",\"dtype\":\"float64\",\"shape\":[50]},\"sigma\":{\"__ndarray__\":\"AAAAAAAAAABX/8krkeHAPwAAAAAAAAAAAAAAAAAAAABSxK0Nmm7FPwAAAAAAAAAALGUZuf0Wzz8AAAAAAAAAAD0fuKXndNE/PMZyuagLzj8AAAAAAAAAAMDsb2dDqcI/APYdmr0/zz8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACf6RRHCMrCPwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGlF43VRSMc/AAAAAAAAAAB+QPuVIR3BP0qEFp0n2ck/T0g6x/Dwyj92p+940FTDP46Irb59bcQ/Jq/ijBP9xj/0lG3lAnfDP9vGrhEiCMU/9t+/XxbazT/wbZ/5rrHRPwoxZDOlmck/wHisVAFAzz+6IDLM+VjPP0Zs/1BAVdA/uhDvQ3zByz82FBZ7SJvMP8XTRUb/g8Q/NH18P2OmvD8UVjy4X3aVPyw3IaQV9Lg/AAAAAAAAAABYeR6xv4C4P32QKwa/IbA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXpTRYIF+uT84IlZ4IWutPw==\",\"dtype\":\"float64\",\"shape\":[50]},\"upper\":{\"__ndarray__\":\"AAAAwEt33D7rT8VT4WDxPwBgHrlliPE/AAAqGAm42D+uO1qqprbNvwAArm5Pidq/S1lOc4A/5j8AAKQ8jYz3P+gDWMQrVQBAyFjCRsRF9j8AABClVFbUP2D2V2cB1tI/wL5rWiBx8j8AAEDxAYX/PwAALsQ1VwNAAADA5yS//j80ndqkQDHzPwAAKJ35lec/AACk3gr49T8AABxDX5wDQFc0N4/gxwlAAAC6KfZoBUAQaOFKivz+P4nQcFSp2fg/hSQj+IN6AEB3usQ2m5AIQIl4mFHPYQ5A8ipA3/DEDEBPKTBRtrgFQG6EjUZtOgFA/3ETM5iVBEC+VVNKLDwNQIgE5bNIpBFAxmXQ1AiKEUAMJc8p5p8MQIlp1qEJSwdADG0yyQiQCECiVozV+zkQQJ7QFNtFrBNA9WNwW2DSE0BW7JXDoIEQQLlByBYmiQtAAABWd5UQC0Dl4Z+oC4QRQEJeFCirYRVAAPA62cwPFkAA0EatL2QTQACwVOQhGhBAUda0ZmQtEEBE3PJsz7USQA==\",\"dtype\":\"float64\",\"shape\":[50]}},\"selected\":{\"id\":\"1351\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"1352\",\"type\":\"UnionRenderers\"}},\"id\":\"1316\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1296\",\"type\":\"PanTool\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"1343\",\"type\":\"Title\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1312\",\"type\":\"Circle\"},{\"attributes\":{\"base\":{\"field\":\"base\",\"units\":\"data\"},\"fill_alpha\":{\"value\":1.0},\"level\":\"underlay\",\"line_color\":{\"value\":\"black\"},\"lower\":{\"field\":\"lower\",\"units\":\"data\"},\"plot\":{\"id\":\"1277\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"source\":{\"id\":\"1316\",\"type\":\"ColumnDataSource\"},\"upper\":{\"field\":\"upper\",\"units\":\"data\"}},\"id\":\"1317\",\"type\":\"Band\"},{\"attributes\":{},\"id\":\"1300\",\"type\":\"ResetTool\"},{\"attributes\":{\"plot\":{\"id\":\"1277\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1287\",\"type\":\"BasicTicker\"}},\"id\":\"1290\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1299\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1347\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"overlay\":{\"id\":\"1304\",\"type\":\"BoxAnnotation\"}},\"id\":\"1298\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"formatter\":{\"id\":\"1347\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"1277\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1292\",\"type\":\"BasicTicker\"}},\"id\":\"1291\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1297\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"1292\",\"type\":\"BasicTicker\"},{\"attributes\":{\"source\":{\"id\":\"1311\",\"type\":\"ColumnDataSource\"}},\"id\":\"1315\",\"type\":\"CDSView\"},{\"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\":\"1304\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"data_source\":{\"id\":\"1311\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"1312\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1313\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"1315\",\"type\":\"CDSView\"}},\"id\":\"1314\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"1277\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1292\",\"type\":\"BasicTicker\"}},\"id\":\"1295\",\"type\":\"Grid\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1313\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1301\",\"type\":\"HelpTool\"}],\"root_ids\":[\"1277\"]},\"title\":\"Bokeh Application\",\"version\":\"1.0.4\"}};\n",
" var render_items = [{\"docid\":\"d905902a-2bd8-463a-ac1a-dc56b2bf2267\",\"roots\":{\"1277\":\"44cd56a5-34cb-4b70-84f4-afc9ba623fcf\"}}];\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": "1277"
}
},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" lower upper base sigma\n",
"0 0.000007 0.000007 0.000000 0.000000\n",
"1 0.822385 1.086152 0.204082 0.131884\n",
"2 1.095800 1.095800 0.408163 0.000000\n",
"3 0.386233 0.386233 0.612245 0.000000\n",
"4 -0.567012 -0.232137 0.816327 0.167438\n",
"5 -0.414631 -0.414631 1.020408 0.000000\n",
"6 0.209473 0.695252 1.224490 0.242889\n",
"7 1.471814 1.471814 1.428571 0.000000\n",
"8 1.496067 2.041587 1.632653 0.272760\n",
"9 0.922571 1.392033 1.836735 0.234731\n",
"10 0.317769 0.317769 2.040816 0.000000\n",
"11 0.002731 0.294312 2.244898 0.145791\n",
"12 0.664353 1.152619 2.448980 0.244133\n",
"13 1.969973 1.969973 2.653061 0.000000\n",
"14 2.417583 2.417583 2.857143 0.000000\n",
"15 1.921666 1.921666 3.061224 0.000000\n",
"16 0.905943 1.199525 3.265306 0.146791\n",
"17 0.737058 0.737058 3.469388 0.000000\n",
"18 1.373057 1.373057 3.673469 0.000000\n",
"19 2.451354 2.451354 3.877551 0.000000\n",
"20 2.858807 3.222596 4.081633 0.181894\n",
"21 2.676251 2.676251 4.285714 0.000000\n",
"22 1.669252 1.936655 4.489796 0.133702\n",
"23 1.149261 1.553140 4.693878 0.201940\n",
"24 1.638866 2.059822 4.897959 0.210478\n",
"25 2.768557 3.070609 5.102041 0.151026\n",
"26 3.478576 3.797759 5.306122 0.159591\n",
"27 3.236966 3.596163 5.510204 0.179598\n",
"28 2.411053 2.715191 5.714286 0.152069\n",
"29 1.824907 2.153529 5.918367 0.164311\n",
"30 2.106608 2.573044 6.122449 0.233218\n",
"31 3.101441 3.654381 6.326531 0.276470\n",
"32 4.010431 4.410434 6.530612 0.200001\n",
"33 3.896518 4.384799 6.734694 0.244141\n",
"34 3.088270 3.578076 6.938776 0.244903\n",
"35 2.401233 2.911639 7.142857 0.255203\n",
"36 2.636645 3.070329 7.346939 0.216842\n",
"37 3.609647 4.056625 7.551020 0.223489\n",
"38 4.597679 4.918235 7.755102 0.160278\n",
"39 4.731618 4.955446 7.959184 0.111914\n",
"40 4.084671 4.126590 8.163265 0.020959\n",
"41 3.247018 3.441967 8.367347 0.097474\n",
"42 3.383098 3.383098 8.571429 0.000000\n",
"43 4.187522 4.378951 8.775510 0.095715\n",
"44 5.219350 5.345379 8.979592 0.063015\n",
"45 5.515430 5.515430 9.183673 0.000000\n",
"46 4.847838 4.847838 9.387755 0.000000\n",
"47 4.025520 4.025520 9.591837 0.000000\n",
"48 3.845155 4.044328 9.795918 0.099587\n",
"49 4.562633 4.677549 10.000000 0.057458\n"
]
}
],
"source": [
"output_notebook()\n",
"sample_x = np.random.uniform(0, 10 ,50)\n",
"sample_y = []\n",
"\n",
"for x in sample_x:\n",
" sample_y.append(func_non_linear(x))\n",
"\n",
"sample_x = np.asarray(sample_x).reshape(-1, 1)\n",
"sample_y = np.asarray(sample_y).reshape(-1, 1)\n",
"\n",
"x_test = np.linspace(0,10,50)\n",
"gpr = GaussianProcessRegressor(random_state=0)\n",
"gpr.fit(sample_x, sample_y)\n",
"y_pred_gaussian, sigma = gpr.predict(x_test.reshape(-1,1), return_std=True)\n",
"sigma *= 100\n",
"\n",
"df = pd.DataFrame(data={\n",
" 'lower' : y_pred_gaussian[:,0]-sigma,\n",
" 'upper' : y_pred_gaussian[:,0]+sigma,\n",
" 'base' : x_test,\n",
" 'sigma' : sigma\n",
" })\n",
"\n",
"p = figure(plot_width=400, plot_height=400)\n",
"p.circle(sample_x[:,0], sample_y[:,0])\n",
"band = Band(base='base', lower='lower', upper='upper', source=ColumnDataSource(df), level='underlay',\n",
" fill_alpha=1.0, line_width=1, line_color='black')\n",
"p.add_layout(band)\n",
"show(p)\n",
"\n",
"print(df)"
]
}
],
"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.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment