|
18 | 18 | "\n", |
19 | 19 | " <div class=\"bk-root\">\n", |
20 | 20 | " <a href=\"https://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n", |
21 | | - " <span id=\"526f94f3-e4ea-43ec-9ee0-c8b7b4137f40\">Loading BokehJS ...</span>\n", |
| 21 | + " <span id=\"07fc1343-da38-4a49-8f32-95b2c52247b6\">Loading BokehJS ...</span>\n", |
22 | 22 | " </div>" |
23 | 23 | ] |
24 | 24 | }, |
|
185 | 185 | " \"</div>\"}};\n", |
186 | 186 | "\n", |
187 | 187 | " function display_loaded() {\n", |
188 | | - " var el = document.getElementById(\"526f94f3-e4ea-43ec-9ee0-c8b7b4137f40\");\n", |
| 188 | + " var el = document.getElementById(\"07fc1343-da38-4a49-8f32-95b2c52247b6\");\n", |
189 | 189 | " if (el != null) {\n", |
190 | 190 | " el.textContent = \"BokehJS is loading...\";\n", |
191 | 191 | " }\n", |
|
239 | 239 | " console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", |
240 | 240 | " document.getElementsByTagName(\"head\")[0].appendChild(s);\n", |
241 | 241 | " }\n", |
242 | | - " };var element = document.getElementById(\"526f94f3-e4ea-43ec-9ee0-c8b7b4137f40\");\n", |
| 242 | + " };var element = document.getElementById(\"07fc1343-da38-4a49-8f32-95b2c52247b6\");\n", |
243 | 243 | " if (element == null) {\n", |
244 | | - " console.log(\"Bokeh: ERROR: autoload.js configured with elementid '526f94f3-e4ea-43ec-9ee0-c8b7b4137f40' but no matching script tag was found. \")\n", |
| 244 | + " console.log(\"Bokeh: ERROR: autoload.js configured with elementid '07fc1343-da38-4a49-8f32-95b2c52247b6' but no matching script tag was found. \")\n", |
245 | 245 | " return false;\n", |
246 | 246 | " }\n", |
247 | 247 | "\n", |
|
278 | 278 | " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", |
279 | 279 | " root._bokeh_failed_load = true;\n", |
280 | 280 | " } else if (force !== true) {\n", |
281 | | - " var cell = $(document.getElementById(\"526f94f3-e4ea-43ec-9ee0-c8b7b4137f40\")).parents('.cell').data().cell;\n", |
| 281 | + " var cell = $(document.getElementById(\"07fc1343-da38-4a49-8f32-95b2c52247b6\")).parents('.cell').data().cell;\n", |
282 | 282 | " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", |
283 | 283 | " }\n", |
284 | 284 | "\n", |
|
295 | 295 | " }\n", |
296 | 296 | "}(window));" |
297 | 297 | ], |
298 | | - "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(\"526f94f3-e4ea-43ec-9ee0-c8b7b4137f40\");\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(\"526f94f3-e4ea-43ec-9ee0-c8b7b4137f40\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '526f94f3-e4ea-43ec-9ee0-c8b7b4137f40' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.13.min.js\"];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n }\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"526f94f3-e4ea-43ec-9ee0-c8b7b4137f40\")).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));" |
| 298 | + "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(\"07fc1343-da38-4a49-8f32-95b2c52247b6\");\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(\"07fc1343-da38-4a49-8f32-95b2c52247b6\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '07fc1343-da38-4a49-8f32-95b2c52247b6' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.13.min.js\"];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n }\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"07fc1343-da38-4a49-8f32-95b2c52247b6\")).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));" |
299 | 299 | }, |
300 | 300 | "metadata": {}, |
301 | 301 | "output_type": "display_data" |
|
339 | 339 | }, |
340 | 340 | { |
341 | 341 | "cell_type": "code", |
342 | | - "execution_count": 2, |
| 342 | + "execution_count": 3, |
343 | 343 | "metadata": {}, |
344 | 344 | "outputs": [ |
345 | 345 | { |
|
397 | 397 | "\n", |
398 | 398 | "X, y = adult_data[adult_data.columns.difference([\"Target\"])], adult_data[\"Target\"]\n", |
399 | 399 | "\n", |
| 400 | + "pickle.dump(encoders, open(\"encoders.pkl\", \"wb\"), protocol=2)\n", |
| 401 | + "\n", |
400 | 402 | "# Train a model\n", |
401 | 403 | "#lr = LogisticRegression()\n", |
402 | 404 | "#lr.fit(X, y)\n", |
|
1500 | 1502 | "\n", |
1501 | 1503 | "=====================\n", |
1502 | 1504 | "Slice description:\n", |
1503 | | - "Hours per week:50 \n", |
1504 | 1505 | "Capital Gain:0 \n", |
| 1506 | + "Hours per week:50 \n", |
1505 | 1507 | "---------------------\n", |
1506 | 1508 | "effect_size: 0.479851077333\n", |
1507 | 1509 | "---------------------\n", |
|
1510 | 1512 | "\n", |
1511 | 1513 | "=====================\n", |
1512 | 1514 | "Slice description:\n", |
1513 | | - "Capital Loss:0 \n", |
1514 | 1515 | "Education:Masters \n", |
| 1516 | + "Capital Loss:0 \n", |
1515 | 1517 | "---------------------\n", |
1516 | 1518 | "effect_size: 0.410478506987\n", |
1517 | 1519 | "---------------------\n", |
|
1520 | 1522 | "\n", |
1521 | 1523 | "=====================\n", |
1522 | 1524 | "Slice description:\n", |
1523 | | - "Capital Loss:0 \n", |
1524 | 1525 | "Education-Num:14 \n", |
| 1526 | + "Capital Loss:0 \n", |
1525 | 1527 | "---------------------\n", |
1526 | 1528 | "effect_size: 0.410478506987\n", |
1527 | 1529 | "---------------------\n", |
|
1539 | 1541 | "\n", |
1540 | 1542 | "=====================\n", |
1541 | 1543 | "Slice description:\n", |
1542 | | - "Capital Gain:0 \n", |
1543 | 1544 | "Education:Masters \n", |
| 1545 | + "Capital Gain:0 \n", |
1544 | 1546 | "---------------------\n", |
1545 | 1547 | "effect_size: 0.525841538236\n", |
1546 | 1548 | "---------------------\n", |
|
1549 | 1551 | "\n", |
1550 | 1552 | "=====================\n", |
1551 | 1553 | "Slice description:\n", |
1552 | | - "Capital Gain:0 \n", |
1553 | 1554 | "Education-Num:14 \n", |
| 1555 | + "Capital Gain:0 \n", |
1554 | 1556 | "---------------------\n", |
1555 | 1557 | "effect_size: 0.525841538236\n", |
1556 | 1558 | "---------------------\n", |
|
1564 | 1566 | "with open('slices.p','rb') as handle:\n", |
1565 | 1567 | " slices = pickle.load(handle)\n", |
1566 | 1568 | "\n", |
| 1569 | + "pickle.dump(slices, open('slices_ver2.pkl','wb'), protocol=2)\n", |
| 1570 | + "\n", |
| 1571 | + "encoders = dict()\n", |
| 1572 | + "with open('encoder')\n", |
| 1573 | + "\n", |
| 1574 | + "slices = list()\n", |
| 1575 | + "with open('slices_ver2.pkl','rb') as handle:\n", |
| 1576 | + " slices = pickle.load(handle)\n", |
| 1577 | + " \n", |
1567 | 1578 | "slices_ = sorted(slices, key=lambda s: s.size, reverse=True) \n", |
1568 | 1579 | "k = 10 \n", |
1569 | 1580 | "for s in slices_[:k]:\n", |
|
0 commit comments