{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", " <div class=\"bk-root\">\n", " <a href=\"http://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n", " <span id=\"f981697c-83d6-4fdb-91b7-84e9dde6b213\">Loading BokehJS ...</span>\n", " </div>" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function(global) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " var force = true;\n", "\n", " if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", " window._bokeh_onload_callbacks = [];\n", " window._bokeh_is_loading = undefined;\n", " }\n", "\n", "\n", " \n", " if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n", " window._bokeh_timeout = Date.now() + 5000;\n", " window._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", " if (window.Bokeh !== undefined) {\n", " var el = document.getElementById(\"f981697c-83d6-4fdb-91b7-84e9dde6b213\");\n", " el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n", " } else if (Date.now() < window._bokeh_timeout) {\n", " setTimeout(display_loaded, 100)\n", " }\n", " }\n", "\n", " function run_callbacks() {\n", " window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", " delete window._bokeh_onload_callbacks\n", " console.info(\"Bokeh: all callbacks have finished\");\n", " }\n", "\n", " function load_libs(js_urls, callback) {\n", " window._bokeh_onload_callbacks.push(callback);\n", " if (window._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", " window._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", " window._bokeh_is_loading--;\n", " if (window._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(\"f981697c-83d6-4fdb-91b7-84e9dde6b213\");\n", " if (element == null) {\n", " console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'f981697c-83d6-4fdb-91b7-84e9dde6b213' 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.5.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.js\"];\n", "\n", " var inline_js = [\n", " function(Bokeh) {\n", " Bokeh.set_log_level(\"info\");\n", " },\n", " \n", " function(Bokeh) {\n", " \n", " },\n", " \n", " function(Bokeh) {\n", " \n", " document.getElementById(\"f981697c-83d6-4fdb-91b7-84e9dde6b213\").textContent = \"BokehJS is loading...\";\n", " },\n", " function(Bokeh) {\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css\");\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.css\");\n", " }\n", " ];\n", "\n", " function run_inline_js() {\n", " \n", " if ((window.Bokeh !== undefined) || (force === true)) {\n", " for (var i = 0; i < inline_js.length; i++) {\n", " inline_js[i](window.Bokeh);\n", " }if (force === true) {\n", " display_loaded();\n", " }} else if (Date.now() < window._bokeh_timeout) {\n", " setTimeout(run_inline_js, 100);\n", " } else if (!window._bokeh_failed_load) {\n", " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", " window._bokeh_failed_load = true;\n", " } else if (force !== true) {\n", " var cell = $(document.getElementById(\"f981697c-83d6-4fdb-91b7-84e9dde6b213\")).parents('.cell').data().cell;\n", " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", " }\n", "\n", " }\n", "\n", " if (window._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", "}(this));" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np\n", "from bokeh.plotting import figure, show, output_notebook\n", "\n", "output_notebook()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## algorithm" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def PCA(X, n_components):\n", " # normalize to zero mean\n", " mu = X.mean(axis=0)\n", " X = X - mu\n", " \n", " # eigenvectors of covariance matrix\n", " sigma = X.T @ X\n", " eigvals, eigvecs = np.linalg.eig(sigma)\n", " \n", " # principal components\n", " order = np.argsort(eigvals)[::-1]\n", " components = eigvecs[:, order[:n_components]]\n", " \n", " # projection\n", " Z = X @ components\n", " \n", " # result\n", " return Z, components" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2D data & principal components" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# generate points\n", "x = np.linspace(0, 13, num=100)\n", "y = x + np.sin(x) - np.cos(x)\n", "\n", "# 2D data\n", "X = np.c_[x, y]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "array([[ 0.72299657, -0.69085162],\n", " [ 0.69085162, 0.72299657]])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# PCA\n", "projection, components = PCA(X, n_components=2)\n", "\n", "# principal components\n", "components" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "array([[ 2705.081, 0. ],\n", " [ 0. , 47.716]])" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# convariance matrix of projected data\n", "(projection.T @ projection).round(3)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# prepare plot data\n", "mean = np.mean(X, axis=0)\n", "extent = projection.min(), projection.max()\n", "angle = np.arctan(components[1] / components[0]) + np.pi * (components[0] < 0)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "\n", " <div class=\"bk-root\">\n", " <div class=\"bk-plotdiv\" id=\"b1bb711e-abc4-4353-8cfd-869ebf78ed30\"></div>\n", " </div>\n", "<script type=\"text/javascript\">\n", " \n", " (function(global) {\n", " function now() {\n", " return new Date();\n", " }\n", " \n", " var force = false;\n", " \n", " if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", " window._bokeh_onload_callbacks = [];\n", " window._bokeh_is_loading = undefined;\n", " }\n", " \n", " \n", " \n", " if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n", " window._bokeh_timeout = Date.now() + 0;\n", " window._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", " if (window.Bokeh !== undefined) {\n", " var el = document.getElementById(\"b1bb711e-abc4-4353-8cfd-869ebf78ed30\");\n", " el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n", " } else if (Date.now() < window._bokeh_timeout) {\n", " setTimeout(display_loaded, 100)\n", " }\n", " }\n", " \n", " function run_callbacks() {\n", " window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", " delete window._bokeh_onload_callbacks\n", " console.info(\"Bokeh: all callbacks have finished\");\n", " }\n", " \n", " function load_libs(js_urls, callback) {\n", " window._bokeh_onload_callbacks.push(callback);\n", " if (window._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", " window._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", " window._bokeh_is_loading--;\n", " if (window._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(\"b1bb711e-abc4-4353-8cfd-869ebf78ed30\");\n", " if (element == null) {\n", " console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'b1bb711e-abc4-4353-8cfd-869ebf78ed30' but no matching script tag was found. \")\n", " return false;\n", " }\n", " \n", " var js_urls = [];\n", " \n", " var inline_js = [\n", " function(Bokeh) {\n", " (function() {\n", " var fn = function() {\n", " var docs_json = {\"723e036d-4b2f-4a8b-87e3-6395286aabc4\":{\"roots\":{\"references\":[{\"attributes\":{\"plot\":{\"id\":\"4b1955bd-92c5-429b-9041-30b9aabc5d90\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"2bbaef19-f0cd-450c-be0e-2f3708a769ba\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"3309b636-98c0-4879-8589-5867365dc17d\",\"type\":\"Circle\"},{\"attributes\":{\"overlay\":{\"id\":\"dbd486d0-65a5-4b8c-b514-40a45d71fff4\",\"type\":\"BoxAnnotation\"},\"plot\":{\"id\":\"4b1955bd-92c5-429b-9041-30b9aabc5d90\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"cecd8ccb-e96e-4190-995f-460a3c3fe439\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"plot\":{\"id\":\"4b1955bd-92c5-429b-9041-30b9aabc5d90\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"0d07b3e7-7d49-4281-8f24-33ee4d19b805\",\"type\":\"SaveTool\"},{\"attributes\":{\"plot\":{\"id\":\"4b1955bd-92c5-429b-9041-30b9aabc5d90\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"1d908ce6-b41f-4162-b8bd-4c516afd20ea\",\"type\":\"ResetTool\"},{\"attributes\":{\"plot\":{\"id\":\"4b1955bd-92c5-429b-9041-30b9aabc5d90\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"24aa94fe-8a6e-49be-8e4a-14e83c98c4f9\",\"type\":\"HelpTool\"},{\"attributes\":{\"callback\":null,\"data\":{}},\"id\":\"d2113d50-fa3c-47b4-a6ad-55044309bb59\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"data_source\":{\"id\":\"3d57f8ae-a86f-4f5d-93c9-8527e1a27b74\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"3bd08d7d-6760-4fe5-930a-4b72a1f2a91c\",\"type\":\"Ray\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"a2c86274-8988-417a-bff1-d08f3bee2913\",\"type\":\"Ray\"},\"selection_glyph\":null},\"id\":\"e803af71-a77f-4ae5-8334-23052c4daf4c\",\"type\":\"GlyphRenderer\"},{\"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\":\"72fa128b-43ea-4c3a-8d1d-fbddd313ab9b\",\"type\":\"Circle\"},{\"attributes\":{\"angle\":{\"units\":\"rad\",\"value\":0.7626662967157858},\"length\":{\"units\":\"data\",\"value\":0},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"line_width\":{\"value\":2},\"x\":{\"value\":6.500000000000001},\"y\":{\"value\":6.467650409265912}},\"id\":\"a2c86274-8988-417a-bff1-d08f3bee2913\",\"type\":\"Ray\"},{\"attributes\":{},\"id\":\"ec893a4d-bea3-4138-bb2c-c3048f900c82\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"angle\":{\"units\":\"rad\",\"value\":2.333462623510682},\"length\":{\"units\":\"data\",\"value\":0},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"line_width\":{\"value\":2},\"x\":{\"value\":6.500000000000001},\"y\":{\"value\":6.467650409265912}},\"id\":\"de18470b-7049-430a-ac23-8e516aed6581\",\"type\":\"Ray\"},{\"attributes\":{\"angle\":{\"units\":\"rad\",\"value\":2.333462623510682},\"length\":{\"units\":\"data\",\"value\":0},\"line_color\":{\"value\":\"green\"},\"line_width\":{\"value\":2},\"x\":{\"value\":6.500000000000001},\"y\":{\"value\":6.467650409265912}},\"id\":\"3dc20b9b-ba66-4228-9353-f0eb4465954c\",\"type\":\"Ray\"},{\"attributes\":{\"data_source\":{\"id\":\"d2113d50-fa3c-47b4-a6ad-55044309bb59\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"3dc20b9b-ba66-4228-9353-f0eb4465954c\",\"type\":\"Ray\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"de18470b-7049-430a-ac23-8e516aed6581\",\"type\":\"Ray\"},\"selection_glyph\":null},\"id\":\"7a90d26c-9804-4d7b-9d38-2464c0eb4628\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"74cdbc60-c042-4b61-a7dc-d0c566e34f02\",\"type\":\"Title\"},{\"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\":\"dbd486d0-65a5-4b8c-b514-40a45d71fff4\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"data_source\":{\"id\":\"5519e549-c44e-419c-9c15-32dc12009804\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"3309b636-98c0-4879-8589-5867365dc17d\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"72fa128b-43ea-4c3a-8d1d-fbddd313ab9b\",\"type\":\"Circle\"},\"selection_glyph\":null},\"id\":\"d39f7a84-a428-4c7f-99c5-4991901539cf\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"2066424e-3981-4893-bbae-7a82ee0fae54\",\"type\":\"PanTool\"},{\"id\":\"2bbaef19-f0cd-450c-be0e-2f3708a769ba\",\"type\":\"WheelZoomTool\"},{\"id\":\"cecd8ccb-e96e-4190-995f-460a3c3fe439\",\"type\":\"BoxZoomTool\"},{\"id\":\"0d07b3e7-7d49-4281-8f24-33ee4d19b805\",\"type\":\"SaveTool\"},{\"id\":\"1d908ce6-b41f-4162-b8bd-4c516afd20ea\",\"type\":\"ResetTool\"},{\"id\":\"24aa94fe-8a6e-49be-8e4a-14e83c98c4f9\",\"type\":\"HelpTool\"}]},\"id\":\"e9c08c92-7669-4c00-b2da-543da4f5a289\",\"type\":\"Toolbar\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":{\"__ndarray__\":\"AAAAAAAAAAB6O0Ni3s7AP3o7Q2LeztA/N9lkk0022T96O0Ni3s7gP1gK1PqVAuU/N9lkk0026T8WqPUrBWrtP3o7Q2LezvA/6aKLLrro8j9YCtT6lQL1P8hxHMdxHPc/N9lkk002+T+mQK1fKVD7Pxao9SsFav0/hQ8++O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Wyq3ckmlBECW93UbUqsGQDvRjKygiQhAS8VgO5o8CkDgSELeYsELQB/VoEbqFQ1AdcvE2fQ4DkD40/YfISoPQECjIHLp6Q9AyLJA79A8EEBAfN8muW0QQBONEYEmiRBAI/dzzfCQEEAbaGlqRocQQFfU3aeibhBA0Ufh1sJJEEDEvFE2mhsQQHKRnOOJzg9AfISL2PRfD0CYURwl/vEOQGDJBekriw5AwZVKyOQxDkBqqEC0U+wNQN05vbtMwA1Af5o7WjOzDUCY8zy34skNQFnJkz6YCA5AgkH17+ByDkClgDG4iQsPQFKeEBmT1A9AZOIeK5RnEEBxJhMnzf0QQM22wQqvrBFAxd/YrYdzEkC8t6VGO1ETQLoH/UxJRBRAMB82GdNKFUAyRAgipGIWQMaq9rQ7iRdA9jly/te7GEDknRAxgvcZQK+2RpYbORtAeyYPT2t9HEC7Td6HLMEdQBPHSOEcAR9AnZXsZgUdIEDOyODScbQgQLoILplgRSFAeeziOnvOIUDN9h+7jU4iQII6rOyLxCJADy0OEJYvI0C5Fc6t/I4jQKDC5ptD4iNAu0MTISQpJEB4NY0sjmMkQHV43ZyokSRAvzCHlNCzJECkQ4Dfl8okQAvniHDC1iRAoghzAUPZJEAIwDjlNtMkQBneTR7hxSRAkFbUzqSyJED8dzcb/5okQPgMIpqAgCRAlNm8bsZkJEBPvZwrc0kkQH+Tu50nMCRA2YZAn3saJEBuH7oR9wkkQH50vh4LACRA5Zuv3Av+I0CABqlzKgUkQJaOZdxvFiRAIUxHULgyJEACe51+r1okQFVS35fNjiRA7pHjO1XPJECiATRUUhwlQOJei9+ZdSVA1Ctlr8raJUAvzlsUT0smQKLJ9HFfxiZAfcJ+rgVLJ0DY6dpvIdgnQFAwhBJtbChAXa3xRIMGKUA=\",\"dtype\":\"float64\",\"shape\":[100]}}},\"id\":\"5519e549-c44e-419c-9c15-32dc12009804\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"below\":[{\"id\":\"181c29e6-6ebd-402c-907b-2ab1d4a1cf93\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"65fde52e-7196-4bd9-a8ea-8c7991d8b6f4\",\"type\":\"LinearAxis\"}],\"renderers\":[{\"id\":\"181c29e6-6ebd-402c-907b-2ab1d4a1cf93\",\"type\":\"LinearAxis\"},{\"id\":\"b3b27d01-d269-412a-9271-06884a66d0f5\",\"type\":\"Grid\"},{\"id\":\"65fde52e-7196-4bd9-a8ea-8c7991d8b6f4\",\"type\":\"LinearAxis\"},{\"id\":\"3c69fec5-a701-49a3-8f4f-9eb9c787a1d5\",\"type\":\"Grid\"},{\"id\":\"dbd486d0-65a5-4b8c-b514-40a45d71fff4\",\"type\":\"BoxAnnotation\"},{\"id\":\"d39f7a84-a428-4c7f-99c5-4991901539cf\",\"type\":\"GlyphRenderer\"},{\"id\":\"e803af71-a77f-4ae5-8334-23052c4daf4c\",\"type\":\"GlyphRenderer\"},{\"id\":\"7a90d26c-9804-4d7b-9d38-2464c0eb4628\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"74cdbc60-c042-4b61-a7dc-d0c566e34f02\",\"type\":\"Title\"},\"tool_events\":{\"id\":\"95ac9029-efdf-49a0-b954-4f25e5abd5da\",\"type\":\"ToolEvents\"},\"toolbar\":{\"id\":\"e9c08c92-7669-4c00-b2da-543da4f5a289\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"83e91bc5-66af-4fd8-b38d-c8fff3ecd8d0\",\"type\":\"DataRange1d\"},\"y_range\":{\"id\":\"d79ceeda-d1a5-4f6d-98c6-abf0245ba622\",\"type\":\"DataRange1d\"}},\"id\":\"4b1955bd-92c5-429b-9041-30b9aabc5d90\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"95ac9029-efdf-49a0-b954-4f25e5abd5da\",\"type\":\"ToolEvents\"},{\"attributes\":{\"callback\":null},\"id\":\"83e91bc5-66af-4fd8-b38d-c8fff3ecd8d0\",\"type\":\"DataRange1d\"},{\"attributes\":{\"callback\":null},\"id\":\"d79ceeda-d1a5-4f6d-98c6-abf0245ba622\",\"type\":\"DataRange1d\"},{\"attributes\":{\"plot\":{\"id\":\"4b1955bd-92c5-429b-9041-30b9aabc5d90\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"bdd0e251-d584-4ece-8c64-d19cac42fbd5\",\"type\":\"BasicTicker\"}},\"id\":\"b3b27d01-d269-412a-9271-06884a66d0f5\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"ec893a4d-bea3-4138-bb2c-c3048f900c82\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"4b1955bd-92c5-429b-9041-30b9aabc5d90\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"bdd0e251-d584-4ece-8c64-d19cac42fbd5\",\"type\":\"BasicTicker\"}},\"id\":\"181c29e6-6ebd-402c-907b-2ab1d4a1cf93\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"bdd0e251-d584-4ece-8c64-d19cac42fbd5\",\"type\":\"BasicTicker\"},{\"attributes\":{\"formatter\":{\"id\":\"f5d93f9b-b5cf-471c-a3aa-3f98083a11ae\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"4b1955bd-92c5-429b-9041-30b9aabc5d90\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"53afc71e-0485-4933-9a56-04522cea2fbe\",\"type\":\"BasicTicker\"}},\"id\":\"65fde52e-7196-4bd9-a8ea-8c7991d8b6f4\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"53afc71e-0485-4933-9a56-04522cea2fbe\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"4b1955bd-92c5-429b-9041-30b9aabc5d90\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"53afc71e-0485-4933-9a56-04522cea2fbe\",\"type\":\"BasicTicker\"}},\"id\":\"3c69fec5-a701-49a3-8f4f-9eb9c787a1d5\",\"type\":\"Grid\"},{\"attributes\":{\"angle\":{\"units\":\"rad\",\"value\":0.7626662967157858},\"length\":{\"units\":\"data\",\"value\":0},\"line_color\":{\"value\":\"red\"},\"line_width\":{\"value\":2},\"x\":{\"value\":6.500000000000001},\"y\":{\"value\":6.467650409265912}},\"id\":\"3bd08d7d-6760-4fe5-930a-4b72a1f2a91c\",\"type\":\"Ray\"},{\"attributes\":{},\"id\":\"f5d93f9b-b5cf-471c-a3aa-3f98083a11ae\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"callback\":null,\"data\":{}},\"id\":\"3d57f8ae-a86f-4f5d-93c9-8527e1a27b74\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"plot\":{\"id\":\"4b1955bd-92c5-429b-9041-30b9aabc5d90\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"2066424e-3981-4893-bbae-7a82ee0fae54\",\"type\":\"PanTool\"}],\"root_ids\":[\"4b1955bd-92c5-429b-9041-30b9aabc5d90\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.5\"}};\n", " var render_items = [{\"docid\":\"723e036d-4b2f-4a8b-87e3-6395286aabc4\",\"elementid\":\"b1bb711e-abc4-4353-8cfd-869ebf78ed30\",\"modelid\":\"4b1955bd-92c5-429b-9041-30b9aabc5d90\"}];\n", " \n", " Bokeh.embed.embed_items(docs_json, render_items);\n", " };\n", " if (document.readyState != \"loading\") fn();\n", " else document.addEventListener(\"DOMContentLoaded\", fn);\n", " })();\n", " },\n", " function(Bokeh) {\n", " }\n", " ];\n", " \n", " function run_inline_js() {\n", " \n", " if ((window.Bokeh !== undefined) || (force === true)) {\n", " for (var i = 0; i < inline_js.length; i++) {\n", " inline_js[i](window.Bokeh);\n", " }if (force === true) {\n", " display_loaded();\n", " }} else if (Date.now() < window._bokeh_timeout) {\n", " setTimeout(run_inline_js, 100);\n", " } else if (!window._bokeh_failed_load) {\n", " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", " window._bokeh_failed_load = true;\n", " } else if (force !== true) {\n", " var cell = $(document.getElementById(\"b1bb711e-abc4-4353-8cfd-869ebf78ed30\")).parents('.cell').data().cell;\n", " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", " }\n", " \n", " }\n", " \n", " if (window._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", " }(this));\n", "</script>" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# plot original data & principal components\n", "plot = figure()\n", "\n", "plot.scatter(x, y)\n", "plot.ray(*mean, length=0, angle=angle[0], line_width=2, line_color='red')\n", "plot.ray(*mean, length=0, angle=angle[1], line_width=2, line_color='green')\n", "\n", "show(plot)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "\n", " <div class=\"bk-root\">\n", " <div class=\"bk-plotdiv\" id=\"02c12ed0-e105-4be6-b6f6-9392f9fc53b8\"></div>\n", " </div>\n", "<script type=\"text/javascript\">\n", " \n", " (function(global) {\n", " function now() {\n", " return new Date();\n", " }\n", " \n", " var force = false;\n", " \n", " if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", " window._bokeh_onload_callbacks = [];\n", " window._bokeh_is_loading = undefined;\n", " }\n", " \n", " \n", " \n", " if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n", " window._bokeh_timeout = Date.now() + 0;\n", " window._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", " if (window.Bokeh !== undefined) {\n", " var el = document.getElementById(\"02c12ed0-e105-4be6-b6f6-9392f9fc53b8\");\n", " el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n", " } else if (Date.now() < window._bokeh_timeout) {\n", " setTimeout(display_loaded, 100)\n", " }\n", " }\n", " \n", " function run_callbacks() {\n", " window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", " delete window._bokeh_onload_callbacks\n", " console.info(\"Bokeh: all callbacks have finished\");\n", " }\n", " \n", " function load_libs(js_urls, callback) {\n", " window._bokeh_onload_callbacks.push(callback);\n", " if (window._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", " window._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", " window._bokeh_is_loading--;\n", " if (window._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(\"02c12ed0-e105-4be6-b6f6-9392f9fc53b8\");\n", " if (element == null) {\n", " console.log(\"Bokeh: ERROR: autoload.js configured with elementid '02c12ed0-e105-4be6-b6f6-9392f9fc53b8' but no matching script tag was found. \")\n", " return false;\n", " }\n", " \n", " var js_urls = [];\n", " \n", " var inline_js = [\n", " function(Bokeh) {\n", " (function() {\n", " var fn = function() {\n", " var docs_json = {\"08935ed2-0d27-4597-a0ab-55f115c82031\":{\"roots\":{\"references\":[{\"attributes\":{\"plot\":{\"id\":\"df921531-2cd2-4dcf-8001-cb383867c0e9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"99c29899-563b-4294-b18f-f906134ef48e\",\"type\":\"BasicTicker\"}},\"id\":\"35685d6a-7f81-4039-9347-39c4b41cb334\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"99c29899-563b-4294-b18f-f906134ef48e\",\"type\":\"BasicTicker\"},{\"attributes\":{\"data_source\":{\"id\":\"1166ceff-5ba9-4e40-a946-4b04e5145be8\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"2b99f51a-2ece-4bc6-81e4-bff012115de2\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"cae31124-cea6-4a02-a01a-35115996d83a\",\"type\":\"Circle\"},\"selection_glyph\":null},\"id\":\"4c083218-30cd-4876-aa18-9db9b24ab02c\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"formatter\":{\"id\":\"0dd1e32b-117b-4cc2-a5af-8d7997b7b647\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"df921531-2cd2-4dcf-8001-cb383867c0e9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"a0e10681-e274-43ee-bfc0-afa872b4eb49\",\"type\":\"BasicTicker\"}},\"id\":\"79053402-e4dc-491a-8467-ad11349dcc87\",\"type\":\"LinearAxis\"},{\"attributes\":{\"formatter\":{\"id\":\"8ec5f35f-8de1-448b-8a9e-8ad9a379bbbc\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"df921531-2cd2-4dcf-8001-cb383867c0e9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"99c29899-563b-4294-b18f-f906134ef48e\",\"type\":\"BasicTicker\"}},\"id\":\"e2c9def8-1431-49ba-b5bd-06bb1661c6e9\",\"type\":\"LinearAxis\"},{\"attributes\":{\"plot\":{\"id\":\"df921531-2cd2-4dcf-8001-cb383867c0e9\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"4e8702ed-74af-4dfb-8e10-4e076f5a4cc4\",\"type\":\"SaveTool\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"2b99f51a-2ece-4bc6-81e4-bff012115de2\",\"type\":\"Circle\"},{\"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\":\"67860dc2-788f-41a9-9bd0-678ef7e347a0\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"bf2763c3-5335-412f-857d-73ba15eef7a5\",\"type\":\"Title\"},{\"attributes\":{\"callback\":null,\"end\":8.875723995994452,\"start\":-9.8585160853027},\"id\":\"fed43654-dac6-47c8-a367-74814930d1b5\",\"type\":\"Range1d\"},{\"attributes\":{},\"id\":\"0dd1e32b-117b-4cc2-a5af-8d7997b7b647\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"8ec5f35f-8de1-448b-8a9e-8ad9a379bbbc\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"df921531-2cd2-4dcf-8001-cb383867c0e9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"a0e10681-e274-43ee-bfc0-afa872b4eb49\",\"type\":\"BasicTicker\"}},\"id\":\"af72f2e3-ea63-4f23-bd4a-eeae92eedd92\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null,\"end\":8.875723995994452,\"start\":-9.8585160853027},\"id\":\"8687127d-3bb7-4e50-b379-67ff37eeec40\",\"type\":\"Range1d\"},{\"attributes\":{\"plot\":{\"id\":\"df921531-2cd2-4dcf-8001-cb383867c0e9\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"7b43bdcf-3185-4ebc-a217-891833182911\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"below\":[{\"id\":\"e2c9def8-1431-49ba-b5bd-06bb1661c6e9\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"79053402-e4dc-491a-8467-ad11349dcc87\",\"type\":\"LinearAxis\"}],\"renderers\":[{\"id\":\"e2c9def8-1431-49ba-b5bd-06bb1661c6e9\",\"type\":\"LinearAxis\"},{\"id\":\"35685d6a-7f81-4039-9347-39c4b41cb334\",\"type\":\"Grid\"},{\"id\":\"79053402-e4dc-491a-8467-ad11349dcc87\",\"type\":\"LinearAxis\"},{\"id\":\"af72f2e3-ea63-4f23-bd4a-eeae92eedd92\",\"type\":\"Grid\"},{\"id\":\"67860dc2-788f-41a9-9bd0-678ef7e347a0\",\"type\":\"BoxAnnotation\"},{\"id\":\"4c083218-30cd-4876-aa18-9db9b24ab02c\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"bf2763c3-5335-412f-857d-73ba15eef7a5\",\"type\":\"Title\"},\"tool_events\":{\"id\":\"5da52c97-5fab-46e6-b4da-9f52cfb68135\",\"type\":\"ToolEvents\"},\"toolbar\":{\"id\":\"ef1b6a11-8ae8-44ed-845e-75347fe53886\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"8687127d-3bb7-4e50-b379-67ff37eeec40\",\"type\":\"Range1d\"},\"y_range\":{\"id\":\"fed43654-dac6-47c8-a367-74814930d1b5\",\"type\":\"Range1d\"}},\"id\":\"df921531-2cd2-4dcf-8001-cb383867c0e9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"663830f0-dd8c-4f0d-ba58-9e234b6d4f1d\",\"type\":\"PanTool\"},{\"id\":\"7b43bdcf-3185-4ebc-a217-891833182911\",\"type\":\"WheelZoomTool\"},{\"id\":\"8e8d71a3-9bb1-4948-839c-48df0826529e\",\"type\":\"BoxZoomTool\"},{\"id\":\"4e8702ed-74af-4dfb-8e10-4e076f5a4cc4\",\"type\":\"SaveTool\"},{\"id\":\"b5410b2f-34e9-4f87-a97f-194a1f2b22c7\",\"type\":\"ResetTool\"},{\"id\":\"f95450f8-0f27-4a54-afae-fb590c41a84f\",\"type\":\"HelpTool\"}]},\"id\":\"ef1b6a11-8ae8-44ed-845e-75347fe53886\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"a0e10681-e274-43ee-bfc0-afa872b4eb49\",\"type\":\"BasicTicker\"},{\"attributes\":{\"overlay\":{\"id\":\"67860dc2-788f-41a9-9bd0-678ef7e347a0\",\"type\":\"BoxAnnotation\"},\"plot\":{\"id\":\"df921531-2cd2-4dcf-8001-cb383867c0e9\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"8e8d71a3-9bb1-4948-839c-48df0826529e\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"plot\":{\"id\":\"df921531-2cd2-4dcf-8001-cb383867c0e9\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"663830f0-dd8c-4f0d-ba58-9e234b6d4f1d\",\"type\":\"PanTool\"},{\"attributes\":{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566r/cguQ5zubpv/QOsr8vxei/CDbcgscZ5798sxAQWevkv6jI1n7pQuK/kIWbXi9X3r/IzteK1mTXv6D0PedsmM+/gE9h6me2vr8=\",\"dtype\":\"float64\",\"shape\":[100]}}},\"id\":\"1166ceff-5ba9-4e40-a946-4b04e5145be8\",\"type\":\"ColumnDataSource\"},{\"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\":\"cae31124-cea6-4a02-a01a-35115996d83a\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"5da52c97-5fab-46e6-b4da-9f52cfb68135\",\"type\":\"ToolEvents\"},{\"attributes\":{\"plot\":{\"id\":\"df921531-2cd2-4dcf-8001-cb383867c0e9\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"f95450f8-0f27-4a54-afae-fb590c41a84f\",\"type\":\"HelpTool\"},{\"attributes\":{\"plot\":{\"id\":\"df921531-2cd2-4dcf-8001-cb383867c0e9\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"b5410b2f-34e9-4f87-a97f-194a1f2b22c7\",\"type\":\"ResetTool\"}],\"root_ids\":[\"df921531-2cd2-4dcf-8001-cb383867c0e9\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.5\"}};\n", " var render_items = [{\"docid\":\"08935ed2-0d27-4597-a0ab-55f115c82031\",\"elementid\":\"02c12ed0-e105-4be6-b6f6-9392f9fc53b8\",\"modelid\":\"df921531-2cd2-4dcf-8001-cb383867c0e9\"}];\n", " \n", " Bokeh.embed.embed_items(docs_json, render_items);\n", " };\n", " if (document.readyState != \"loading\") fn();\n", " else document.addEventListener(\"DOMContentLoaded\", fn);\n", " })();\n", " },\n", " function(Bokeh) {\n", " }\n", " ];\n", " \n", " function run_inline_js() {\n", " \n", " if ((window.Bokeh !== undefined) || (force === true)) {\n", " for (var i = 0; i < inline_js.length; i++) {\n", " inline_js[i](window.Bokeh);\n", " }if (force === true) {\n", " display_loaded();\n", " }} else if (Date.now() < window._bokeh_timeout) {\n", " setTimeout(run_inline_js, 100);\n", " } else if (!window._bokeh_failed_load) {\n", " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", " window._bokeh_failed_load = true;\n", " } else if (force !== true) {\n", " var cell = $(document.getElementById(\"02c12ed0-e105-4be6-b6f6-9392f9fc53b8\")).parents('.cell').data().cell;\n", " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", " }\n", " \n", " }\n", " \n", " if (window._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", " }(this));\n", "</script>" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# plot projected data\n", "plot = figure(x_range=extent, y_range=extent)\n", "plot.scatter(projection[:, 0], projection[:, 1])\n", "show(plot)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## binary vectors & dimensionality reduction" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# generate binary vectors\n", "X = np.random.rand(90, 30)\n", "X[:30, :] = X[:30, :] < ([.4] * 10 + [.1] * 10 + [.1] * 10)\n", "X[30:60, :] = X[30:60, :] < ([.1] * 10 + [.4] * 10 + [.1] * 10)\n", "X[60:, :] = X[60:, :] < ([.1] * 10 + [.1] * 10 + [.4] * 10)\n", "\n", "# define 3 classes\n", "Y = ['red'] * 30 + ['green'] * 30 + ['blue'] * 30" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# PCA\n", "projection, _ = PCA(X, n_components=2)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "\n", " <div class=\"bk-root\">\n", " <div class=\"bk-plotdiv\" id=\"0d0671d4-4340-4a0f-aecb-b807d07c8427\"></div>\n", " </div>\n", "<script type=\"text/javascript\">\n", " \n", " (function(global) {\n", " function now() {\n", " return new Date();\n", " }\n", " \n", " var force = false;\n", " \n", " if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", " window._bokeh_onload_callbacks = [];\n", " window._bokeh_is_loading = undefined;\n", " }\n", " \n", " \n", " \n", " if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n", " window._bokeh_timeout = Date.now() + 0;\n", " window._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", " if (window.Bokeh !== undefined) {\n", " var el = document.getElementById(\"0d0671d4-4340-4a0f-aecb-b807d07c8427\");\n", " el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n", " } else if (Date.now() < window._bokeh_timeout) {\n", " setTimeout(display_loaded, 100)\n", " }\n", " }\n", " \n", " function run_callbacks() {\n", " window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", " delete window._bokeh_onload_callbacks\n", " console.info(\"Bokeh: all callbacks have finished\");\n", " }\n", " \n", " function load_libs(js_urls, callback) {\n", " window._bokeh_onload_callbacks.push(callback);\n", " if (window._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", " window._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", " window._bokeh_is_loading--;\n", " if (window._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(\"0d0671d4-4340-4a0f-aecb-b807d07c8427\");\n", " if (element == null) {\n", " console.log(\"Bokeh: ERROR: autoload.js configured with elementid '0d0671d4-4340-4a0f-aecb-b807d07c8427' but no matching script tag was found. \")\n", " return false;\n", " }\n", " \n", " var js_urls = [];\n", " \n", " var inline_js = [\n", " function(Bokeh) {\n", " (function() {\n", " var fn = function() {\n", " var docs_json = {\"ac85ef95-f742-42bb-9af1-cd04978af42d\":{\"roots\":{\"references\":[{\"attributes\":{\"formatter\":{\"id\":\"f7dd9b82-5f23-4947-9a26-0d0f615d10b2\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"aa746f96-ab29-48c6-9748-ec6298b98562\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"437c8383-7963-49f7-a3fb-e6ef03ae8429\",\"type\":\"BasicTicker\"}},\"id\":\"c8d2795e-aea8-460c-afb4-6183cbf77a1a\",\"type\":\"LinearAxis\"},{\"attributes\":{\"plot\":{\"id\":\"aa746f96-ab29-48c6-9748-ec6298b98562\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"b23aa937-031f-4d8d-b00e-a61fbeede379\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1709e330-d4c1-4ea4-91f3-cd81b4d714ad\",\"type\":\"ToolEvents\"},{\"attributes\":{\"formatter\":{\"id\":\"13e9ef89-d5a3-4743-95d9-8a862a1f38f8\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"aa746f96-ab29-48c6-9748-ec6298b98562\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"21b71c24-1524-44e1-8312-b46496a267bb\",\"type\":\"BasicTicker\"}},\"id\":\"3750990c-6b29-4f42-8e5f-ab18af38bba8\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null},\"id\":\"fa90b852-dc4b-4d28-b3c6-7f8c173c26f9\",\"type\":\"DataRange1d\"},{\"attributes\":{\"below\":[{\"id\":\"3750990c-6b29-4f42-8e5f-ab18af38bba8\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"c8d2795e-aea8-460c-afb4-6183cbf77a1a\",\"type\":\"LinearAxis\"}],\"renderers\":[{\"id\":\"3750990c-6b29-4f42-8e5f-ab18af38bba8\",\"type\":\"LinearAxis\"},{\"id\":\"f5817a1e-659f-45eb-a447-c5ebd21204b4\",\"type\":\"Grid\"},{\"id\":\"c8d2795e-aea8-460c-afb4-6183cbf77a1a\",\"type\":\"LinearAxis\"},{\"id\":\"349ace6d-5584-47e5-856b-7e6f52f4a5db\",\"type\":\"Grid\"},{\"id\":\"94339170-f649-42f9-bb6a-8b6282ad10ff\",\"type\":\"BoxAnnotation\"},{\"id\":\"70da5cd5-03fb-49d2-80ed-e1e83e454d96\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"8f1fcbc4-bf42-4ee0-b563-8a3c6a6b38e1\",\"type\":\"Title\"},\"tool_events\":{\"id\":\"1709e330-d4c1-4ea4-91f3-cd81b4d714ad\",\"type\":\"ToolEvents\"},\"toolbar\":{\"id\":\"442ad389-6bb7-4750-a4f9-9432573a99de\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"b96e4cc5-5ab8-4e06-aa08-577ab5efedbe\",\"type\":\"DataRange1d\"},\"y_range\":{\"id\":\"fa90b852-dc4b-4d28-b3c6-7f8c173c26f9\",\"type\":\"DataRange1d\"}},\"id\":\"aa746f96-ab29-48c6-9748-ec6298b98562\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"overlay\":{\"id\":\"94339170-f649-42f9-bb6a-8b6282ad10ff\",\"type\":\"BoxAnnotation\"},\"plot\":{\"id\":\"aa746f96-ab29-48c6-9748-ec6298b98562\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"9f11656c-764a-4e55-94ca-0b861a3f0738\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"data_source\":{\"id\":\"27ba90aa-8bd7-40c9-af0a-d27501ea9f5b\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"74088513-dcfc-4073-be11-0c1f6362e53e\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"24a6e59f-3157-4c32-938c-35fa176daae6\",\"type\":\"Circle\"},\"selection_glyph\":null},\"id\":\"70da5cd5-03fb-49d2-80ed-e1e83e454d96\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"8f1fcbc4-bf42-4ee0-b563-8a3c6a6b38e1\",\"type\":\"Title\"},{\"attributes\":{\"plot\":{\"id\":\"aa746f96-ab29-48c6-9748-ec6298b98562\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"21b71c24-1524-44e1-8312-b46496a267bb\",\"type\":\"BasicTicker\"}},\"id\":\"f5817a1e-659f-45eb-a447-c5ebd21204b4\",\"type\":\"Grid\"},{\"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\":\"94339170-f649-42f9-bb6a-8b6282ad10ff\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"plot\":{\"id\":\"aa746f96-ab29-48c6-9748-ec6298b98562\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"cceee814-90d2-4867-b231-8d1b5c61e076\",\"type\":\"HelpTool\"},{\"attributes\":{\"plot\":{\"id\":\"aa746f96-ab29-48c6-9748-ec6298b98562\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"7f545649-b4b4-4eeb-9ad6-1a61c30cf1a6\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"437c8383-7963-49f7-a3fb-e6ef03ae8429\",\"type\":\"BasicTicker\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\",\"fill_color\",\"line_color\"],\"data\":{\"fill_color\":[\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\"],\"line_color\":[\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"red\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"green\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\",\"blue\"],\"x\":{\"__ndarray__\":\"GMH/R+5N0z8sTtG+rR7ZP/uTWDnGt+K/GI6pCPH14z9w9oPNa/20P+DwAXlZ0M0/shvoFO8Zsz+I00gJBpuuPwmLQd7YdsM/GHznl8TK0T+v+YXd6S/lvwwThdua8dQ/GK7R2k/H2D+nVltJDgXBv4iLxlE/+Lo/pwzG8+yb5T8g4DtadFzgP1zTCSIcPuA/9pB4l1wD4D+wWYyCrunGPw3TYpdKFeY/pPVDwDWI3D88f5Wrdj3ZP5SMc1ldG+Y/HNbPT03otL/adcO7a3HUP4iiPiyN9pE/Puyulsxr4T82pL5Y1PK/vxtd5zLlYcM/2l4HsA4d7z/aFBgaUxnXP5iY0gF9nZK/jGJ2jyHW0D/sp2lgqALkP29F13YSseg/XiVC7uLu8D8Sq7/f/4DwP8G7cahEGO8/sa87cTzgzj+ANThvByJwv5kKJDYZA/I/bgua+Unb6T8YI3qGLlPnP7aek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ickOc/pHoz3y4uyj9CxrRgMRTkP+3szSo8xo6/zaZ1M6rfwL+6KUhJcZ/bP3FFXfqmUuA/brNRe7uG6D9cpq2g+BPXP8ohBNF/ruQ/+UwEoglOyz/6WkATdBaav+wOqBiJ7NE/msQKu3p43z+DSW+KzwC0Pz3wMsfgfeo/q5TcRh8Ixz9tf0P1awOqv1b4k+695s4/oYr9bzJOvj8/KcHamgTBP6rtGImsFdC/o/BGIgs+3D8seMVHTc/Lv97YlpDlqNI/VNcgFAyfrz//gbPu/+/gP7hJ17j0T3Q/M5U+3PcjtT/vjHI6i/Wjv78epN3Duuy/PJ7fr8Pm1j/iHpCgPMLQv5sqcclb/cs/jl7tQaIP4z+FMz8bEvvtP9Pw3yfrCNM/sZfeL2/Wn7/JGy17r2yiv6LIgI38G9+/\",\"dtype\":\"float64\",\"shape\":[90]}}},\"id\":\"27ba90aa-8bd7-40c9-af0a-d27501ea9f5b\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"f7dd9b82-5f23-4947-9a26-0d0f615d10b2\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1962b823-c1d0-4810-b1ab-1aa1b2bb40dc\",\"type\":\"PanTool\"},{\"id\":\"b44f8c38-773c-49a8-b1bf-082ed9681bd1\",\"type\":\"WheelZoomTool\"},{\"id\":\"9f11656c-764a-4e55-94ca-0b861a3f0738\",\"type\":\"BoxZoomTool\"},{\"id\":\"b23aa937-031f-4d8d-b00e-a61fbeede379\",\"type\":\"SaveTool\"},{\"id\":\"7f545649-b4b4-4eeb-9ad6-1a61c30cf1a6\",\"type\":\"ResetTool\"},{\"id\":\"cceee814-90d2-4867-b231-8d1b5c61e076\",\"type\":\"HelpTool\"}]},\"id\":\"442ad389-6bb7-4750-a4f9-9432573a99de\",\"type\":\"Toolbar\"},{\"attributes\":{\"plot\":{\"id\":\"aa746f96-ab29-48c6-9748-ec6298b98562\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"1962b823-c1d0-4810-b1ab-1aa1b2bb40dc\",\"type\":\"PanTool\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"aa746f96-ab29-48c6-9748-ec6298b98562\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"437c8383-7963-49f7-a3fb-e6ef03ae8429\",\"type\":\"BasicTicker\"}},\"id\":\"349ace6d-5584-47e5-856b-7e6f52f4a5db\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null},\"id\":\"b96e4cc5-5ab8-4e06-aa08-577ab5efedbe\",\"type\":\"DataRange1d\"},{\"attributes\":{\"fill_color\":{\"field\":\"fill_color\"},\"line_color\":{\"field\":\"line_color\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"74088513-dcfc-4073-be11-0c1f6362e53e\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"21b71c24-1524-44e1-8312-b46496a267bb\",\"type\":\"BasicTicker\"},{\"attributes\":{\"plot\":{\"id\":\"aa746f96-ab29-48c6-9748-ec6298b98562\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"b44f8c38-773c-49a8-b1bf-082ed9681bd1\",\"type\":\"WheelZoomTool\"},{\"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\":\"24a6e59f-3157-4c32-938c-35fa176daae6\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"13e9ef89-d5a3-4743-95d9-8a862a1f38f8\",\"type\":\"BasicTickFormatter\"}],\"root_ids\":[\"aa746f96-ab29-48c6-9748-ec6298b98562\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.5\"}};\n", " var render_items = [{\"docid\":\"ac85ef95-f742-42bb-9af1-cd04978af42d\",\"elementid\":\"0d0671d4-4340-4a0f-aecb-b807d07c8427\",\"modelid\":\"aa746f96-ab29-48c6-9748-ec6298b98562\"}];\n", " \n", " Bokeh.embed.embed_items(docs_json, render_items);\n", " };\n", " if (document.readyState != \"loading\") fn();\n", " else document.addEventListener(\"DOMContentLoaded\", fn);\n", " })();\n", " },\n", " function(Bokeh) {\n", " }\n", " ];\n", " \n", " function run_inline_js() {\n", " \n", " if ((window.Bokeh !== undefined) || (force === true)) {\n", " for (var i = 0; i < inline_js.length; i++) {\n", " inline_js[i](window.Bokeh);\n", " }if (force === true) {\n", " display_loaded();\n", " }} else if (Date.now() < window._bokeh_timeout) {\n", " setTimeout(run_inline_js, 100);\n", " } else if (!window._bokeh_failed_load) {\n", " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", " window._bokeh_failed_load = true;\n", " } else if (force !== true) {\n", " var cell = $(document.getElementById(\"0d0671d4-4340-4a0f-aecb-b807d07c8427\")).parents('.cell').data().cell;\n", " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", " }\n", " \n", " }\n", " \n", " if (window._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", " }(this));\n", "</script>" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# plot projected data: 30D -> 2D\n", "plot = figure()\n", "plot.scatter(projection[:, 0], projection[:, 1], color=Y)\n", "show(plot)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "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.0" } }, "nbformat": 4, "nbformat_minor": 2 }