Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brt-h/1ce1d527dc3e4e7ea378b51a7f5e0dde to your computer and use it in GitHub Desktop.
Save brt-h/1ce1d527dc3e4e7ea378b51a7f5e0dde to your computer and use it in GitHub Desktop.
Applied Data Science Capstone
{
"cells": [
{
"cell_type": "markdown",
"id": "bff5089e-aa10-401d-9e00-a4ffd788ec7d",
"metadata": {},
"source": [
"### Hands-on Lab: Build an Interactive Dashboard with Ploty Dash\n",
"Rather than using the provided theiadocker instance that does not persist data, I am adapting the assignment to be run on jupyter notebook, original assignment instructions here: https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBM-DS0321EN-SkillsNetwork/labs/module_3/lab_theia_plotly_dash.md.html - brt-h"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e2a644d7-26bd-40e2-95cd-4f2bcf506587",
"metadata": {},
"outputs": [],
"source": [
"# note that this notebook is not currently working correctly, there is a bug with the proxy config"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "6cfffa60-ff59-4fa8-9a8f-064f7c50b119",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: dash in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (1.19.0)\n",
"Requirement already satisfied: Flask>=1.0.4 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash) (2.0.1)\n",
"Requirement already satisfied: dash-core-components==1.15.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash) (1.15.0)\n",
"Requirement already satisfied: plotly in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash) (5.3.1)\n",
"Requirement already satisfied: dash-html-components==1.1.2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash) (1.1.2)\n",
"Requirement already satisfied: flask-compress in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash) (0.0.0)\n",
"Requirement already satisfied: dash-table==4.11.2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash) (4.11.2)\n",
"Requirement already satisfied: future in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash) (0.18.2)\n",
"Requirement already satisfied: dash-renderer==1.9.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash) (1.9.0)\n",
"Requirement already satisfied: itsdangerous>=2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from Flask>=1.0.4->dash) (2.0.1)\n",
"Requirement already satisfied: click>=7.1.2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from Flask>=1.0.4->dash) (8.0.1)\n",
"Requirement already satisfied: Jinja2>=3.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from Flask>=1.0.4->dash) (3.0.1)\n",
"Requirement already satisfied: Werkzeug>=2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from Flask>=1.0.4->dash) (2.0.1)\n",
"Requirement already satisfied: importlib-metadata in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from click>=7.1.2->Flask>=1.0.4->dash) (4.8.1)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from Jinja2>=3.0->Flask>=1.0.4->dash) (2.0.1)\n",
"Requirement already satisfied: brotli in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from flask-compress->dash) (1.0.9)\n",
"Requirement already satisfied: typing-extensions>=3.6.4 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from importlib-metadata->click>=7.1.2->Flask>=1.0.4->dash) (3.10.0.2)\n",
"Requirement already satisfied: zipp>=0.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from importlib-metadata->click>=7.1.2->Flask>=1.0.4->dash) (3.5.0)\n",
"Requirement already satisfied: six in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from plotly->dash) (1.16.0)\n",
"Requirement already satisfied: tenacity>=6.2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from plotly->dash) (8.0.1)\n",
"Requirement already satisfied: dash==1.19.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (1.19.0)\n",
"Requirement already satisfied: Flask>=1.0.4 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash==1.19.0) (2.0.1)\n",
"Requirement already satisfied: dash-core-components==1.15.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash==1.19.0) (1.15.0)\n",
"Requirement already satisfied: plotly in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash==1.19.0) (5.3.1)\n",
"Requirement already satisfied: dash-html-components==1.1.2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash==1.19.0) (1.1.2)\n",
"Requirement already satisfied: flask-compress in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash==1.19.0) (0.0.0)\n",
"Requirement already satisfied: dash-table==4.11.2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash==1.19.0) (4.11.2)\n",
"Requirement already satisfied: future in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash==1.19.0) (0.18.2)\n",
"Requirement already satisfied: dash-renderer==1.9.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash==1.19.0) (1.9.0)\n",
"Requirement already satisfied: itsdangerous>=2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from Flask>=1.0.4->dash==1.19.0) (2.0.1)\n",
"Requirement already satisfied: click>=7.1.2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from Flask>=1.0.4->dash==1.19.0) (8.0.1)\n",
"Requirement already satisfied: Jinja2>=3.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from Flask>=1.0.4->dash==1.19.0) (3.0.1)\n",
"Requirement already satisfied: Werkzeug>=2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from Flask>=1.0.4->dash==1.19.0) (2.0.1)\n",
"Requirement already satisfied: importlib-metadata in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from click>=7.1.2->Flask>=1.0.4->dash==1.19.0) (4.8.1)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from Jinja2>=3.0->Flask>=1.0.4->dash==1.19.0) (2.0.1)\n",
"Requirement already satisfied: brotli in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from flask-compress->dash==1.19.0) (1.0.9)\n",
"Requirement already satisfied: typing-extensions>=3.6.4 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from importlib-metadata->click>=7.1.2->Flask>=1.0.4->dash==1.19.0) (3.10.0.2)\n",
"Requirement already satisfied: zipp>=0.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from importlib-metadata->click>=7.1.2->Flask>=1.0.4->dash==1.19.0) (3.5.0)\n",
"Requirement already satisfied: six in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from plotly->dash==1.19.0) (1.16.0)\n",
"Requirement already satisfied: tenacity>=6.2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from plotly->dash==1.19.0) (8.0.1)\n",
"Requirement already satisfied: jupyter_dash in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (0.4.0)\n",
"Requirement already satisfied: requests in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jupyter_dash) (2.26.0)\n",
"Requirement already satisfied: flask in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jupyter_dash) (2.0.1)\n",
"Requirement already satisfied: dash in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jupyter_dash) (1.19.0)\n",
"Requirement already satisfied: ipykernel in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jupyter_dash) (6.4.1)\n",
"Requirement already satisfied: retrying in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jupyter_dash) (1.3.3)\n",
"Requirement already satisfied: ansi2html in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jupyter_dash) (0.0.0)\n",
"Requirement already satisfied: ipython in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jupyter_dash) (7.28.0)\n",
"Requirement already satisfied: dash-core-components==1.15.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash->jupyter_dash) (1.15.0)\n",
"Requirement already satisfied: plotly in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash->jupyter_dash) (5.3.1)\n",
"Requirement already satisfied: dash-html-components==1.1.2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash->jupyter_dash) (1.1.2)\n",
"Requirement already satisfied: flask-compress in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash->jupyter_dash) (0.0.0)\n",
"Requirement already satisfied: dash-table==4.11.2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash->jupyter_dash) (4.11.2)\n",
"Requirement already satisfied: future in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash->jupyter_dash) (0.18.2)\n",
"Requirement already satisfied: dash-renderer==1.9.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from dash->jupyter_dash) (1.9.0)\n",
"Requirement already satisfied: itsdangerous>=2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from flask->jupyter_dash) (2.0.1)\n",
"Requirement already satisfied: click>=7.1.2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from flask->jupyter_dash) (8.0.1)\n",
"Requirement already satisfied: Jinja2>=3.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from flask->jupyter_dash) (3.0.1)\n",
"Requirement already satisfied: Werkzeug>=2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from flask->jupyter_dash) (2.0.1)\n",
"Requirement already satisfied: importlib-metadata in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from click>=7.1.2->flask->jupyter_dash) (4.8.1)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from Jinja2>=3.0->flask->jupyter_dash) (2.0.1)\n",
"Requirement already satisfied: brotli in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from flask-compress->dash->jupyter_dash) (1.0.9)\n",
"Requirement already satisfied: typing-extensions>=3.6.4 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from importlib-metadata->click>=7.1.2->flask->jupyter_dash) (3.10.0.2)\n",
"Requirement already satisfied: zipp>=0.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from importlib-metadata->click>=7.1.2->flask->jupyter_dash) (3.5.0)\n",
"Requirement already satisfied: traitlets<6.0,>=4.1.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipykernel->jupyter_dash) (5.1.0)\n",
"Requirement already satisfied: ipython-genutils in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipykernel->jupyter_dash) (0.2.0)\n",
"Requirement already satisfied: matplotlib-inline<0.2.0,>=0.1.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipykernel->jupyter_dash) (0.1.3)\n",
"Requirement already satisfied: debugpy<2.0,>=1.0.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipykernel->jupyter_dash) (1.4.1)\n",
"Requirement already satisfied: tornado<7.0,>=4.2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipykernel->jupyter_dash) (6.1)\n",
"Requirement already satisfied: argcomplete>=1.12.3 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipykernel->jupyter_dash) (1.12.3)\n",
"Requirement already satisfied: jupyter-client<8.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipykernel->jupyter_dash) (7.0.3)\n",
"Requirement already satisfied: jedi>=0.16 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipython->jupyter_dash) (0.18.0)\n",
"Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipython->jupyter_dash) (3.0.20)\n",
"Requirement already satisfied: pexpect>4.3 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipython->jupyter_dash) (4.8.0)\n",
"Requirement already satisfied: pickleshare in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipython->jupyter_dash) (0.7.5)\n",
"Requirement already satisfied: backcall in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipython->jupyter_dash) (0.2.0)\n",
"Requirement already satisfied: decorator in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipython->jupyter_dash) (4.4.2)\n",
"Requirement already satisfied: pygments in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipython->jupyter_dash) (2.10.0)\n",
"Requirement already satisfied: setuptools>=18.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from ipython->jupyter_dash) (58.0.4)\n",
"Requirement already satisfied: parso<0.9.0,>=0.8.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jedi>=0.16->ipython->jupyter_dash) (0.8.2)\n",
"Requirement already satisfied: nest-asyncio>=1.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jupyter-client<8.0->ipykernel->jupyter_dash) (1.5.1)\n",
"Requirement already satisfied: entrypoints in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jupyter-client<8.0->ipykernel->jupyter_dash) (0.3)\n",
"Requirement already satisfied: jupyter-core>=4.6.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jupyter-client<8.0->ipykernel->jupyter_dash) (4.8.1)\n",
"Requirement already satisfied: python-dateutil>=2.1 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jupyter-client<8.0->ipykernel->jupyter_dash) (2.8.2)\n",
"Requirement already satisfied: pyzmq>=13 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from jupyter-client<8.0->ipykernel->jupyter_dash) (22.3.0)\n",
"Requirement already satisfied: ptyprocess>=0.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from pexpect>4.3->ipython->jupyter_dash) (0.7.0)\n",
"Requirement already satisfied: wcwidth in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython->jupyter_dash) (0.2.5)\n",
"Requirement already satisfied: six>=1.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from python-dateutil>=2.1->jupyter-client<8.0->ipykernel->jupyter_dash) (1.16.0)\n",
"Requirement already satisfied: tenacity>=6.2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from plotly->dash->jupyter_dash) (8.0.1)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests->jupyter_dash) (2021.5.30)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests->jupyter_dash) (1.26.7)\n",
"Requirement already satisfied: idna<4,>=2.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests->jupyter_dash) (3.1)\n",
"Requirement already satisfied: charset-normalizer~=2.0.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests->jupyter_dash) (2.0.0)\n",
"Requirement already satisfied: plotly in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (5.3.1)\n",
"Requirement already satisfied: six in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from plotly) (1.16.0)\n",
"Requirement already satisfied: tenacity>=6.2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from plotly) (8.0.1)\n"
]
}
],
"source": [
"!pip install dash\n",
"!pip install dash==1.19.0\n",
"!pip install jupyter_dash\n",
"!pip install --upgrade plotly"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9ceea910-97b3-4d8b-84c4-7833b0127e71",
"metadata": {},
"outputs": [],
"source": [
"from jupyter_dash.comms import _send_jupyter_config_comm_request\n",
"_send_jupyter_config_comm_request()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "22c56070-11cd-4f40-ad9d-bd1d600fcd53",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import dash\n",
"import dash_html_components as html\n",
"import dash_core_components as dcc\n",
"from dash.dependencies import Input, Output\n",
"from jupyter_dash import JupyterDash\n",
"import plotly.graph_objects as go"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "7d6ce49c-1a48-4b92-9bdc-177c050aba38",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Package Version\n",
"------------------------------- ---------\n",
"absl-py 0.14.0\n",
"ansi2html 0.0.0\n",
"argcomplete 1.12.3\n",
"argon2-cffi 21.1.0\n",
"astor 0.8.1\n",
"attrs 21.2.0\n",
"autobahn 21.3.1\n",
"Automat 20.2.0\n",
"backcall 0.2.0\n",
"backports.functools-lru-cache 1.6.4\n",
"basemap 1.2.0\n",
"bleach 4.1.0\n",
"boto3 1.7.62\n",
"botocore 1.10.84\n",
"branca 0.4.2\n",
"Brotli 1.0.9\n",
"brotlipy 0.7.0\n",
"certifi 2021.5.30\n",
"cffi 1.14.6\n",
"chardet 4.0.0\n",
"charset-normalizer 2.0.0\n",
"click 8.0.1\n",
"cloudpickle 2.0.0\n",
"colorama 0.4.4\n",
"constantly 15.1.0\n",
"contextlib2 21.6.0\n",
"cryptography 3.4.7\n",
"cycler 0.10.0\n",
"Cython 0.29.24\n",
"cytoolz 0.11.0\n",
"dash 1.19.0\n",
"dash-core-components 1.15.0\n",
"dash-html-components 1.1.2\n",
"dash-renderer 1.9.0\n",
"dash-table 4.11.2\n",
"dask 2021.9.1\n",
"dataclasses 0.8\n",
"debugpy 1.4.1\n",
"decorator 4.4.2\n",
"defusedxml 0.7.1\n",
"docutils 0.17.1\n",
"entrypoints 0.3\n",
"Flask 2.0.1\n",
"Flask-Compress 0.0.0\n",
"folium 0.5.0\n",
"fsspec 2021.9.0\n",
"future 0.18.2\n",
"gast 0.5.0\n",
"google-pasta 0.2.0\n",
"grpcio 1.38.1\n",
"h5py 2.8.0\n",
"hyperlink 21.0.0\n",
"ibm-cos-sdk 2.0.1\n",
"ibm-cos-sdk-core 2.10.0\n",
"ibm-cos-sdk-s3transfer 2.10.0\n",
"ibm-db 3.0.4\n",
"ibm-db-sa 0.3.3\n",
"idna 3.1\n",
"imagecodecs-lite 2019.12.3\n",
"imageio 2.4.1\n",
"importlib-metadata 4.8.1\n",
"imutils 0.5.4\n",
"incremental 21.3.0\n",
"ipykernel 6.4.1\n",
"ipython 7.28.0\n",
"ipython-genutils 0.2.0\n",
"ipython-sql 0.3.9\n",
"ipywidgets 7.4.2\n",
"itsdangerous 2.0.1\n",
"jedi 0.18.0\n",
"jeepney 0.7.1\n",
"Jinja2 3.0.1\n",
"jmespath 0.10.0\n",
"jsonschema 3.2.0\n",
"jupyter 1.0.0\n",
"jupyter-client 7.0.3\n",
"jupyter-console 6.4.0\n",
"jupyter-core 4.8.1\n",
"jupyter-dash 0.4.0\n",
"jupyterlab-pygments 0.1.2\n",
"Keras 2.1.6\n",
"Keras-Applications 1.0.8\n",
"Keras-Preprocessing 1.1.2\n",
"keyring 23.2.1\n",
"kiwisolver 1.3.2\n",
"libarchive-c 2.8\n",
"locket 0.2.0\n",
"lxml 4.6.3\n",
"Markdown 3.3.4\n",
"MarkupSafe 2.0.1\n",
"matplotlib 3.4.3\n",
"matplotlib-inline 0.1.3\n",
"mistune 0.8.4\n",
"nbclient 0.5.4\n",
"nbconvert 6.2.0\n",
"nbformat 5.1.3\n",
"nest-asyncio 1.5.1\n",
"networkx 2.6.3\n",
"notebook 6.4.4\n",
"numpy 1.21.2\n",
"olefile 0.46\n",
"packaging 21.0\n",
"pandas 1.3.3\n",
"pandocfilters 1.5.0\n",
"parso 0.8.2\n",
"partd 1.2.0\n",
"patsy 0.5.2\n",
"pexpect 4.8.0\n",
"pickleshare 0.7.5\n",
"Pillow 8.1.0\n",
"pip 21.2.4\n",
"pkginfo 1.7.1\n",
"plotly 5.3.1\n",
"prettytable 2.2.1\n",
"prometheus-client 0.11.0\n",
"prompt-toolkit 3.0.20\n",
"protobuf 3.18.0\n",
"ptyprocess 0.7.0\n",
"pyasn1 0.4.8\n",
"pyasn1-modules 0.2.8\n",
"pycocotools 2.0.2\n",
"pycparser 2.20\n",
"pydotplus 2.0.2\n",
"Pygments 2.10.0\n",
"pyOpenSSL 20.0.1\n",
"pyparsing 2.4.7\n",
"pyproj 1.9.6\n",
"pyrsistent 0.18.0\n",
"pyshp 2.1.3\n",
"PySocks 1.7.1\n",
"python-dateutil 2.8.2\n",
"pytz 2021.1\n",
"PyWavelets 1.1.1\n",
"PyYAML 5.4.1\n",
"pyzmq 22.3.0\n",
"qtconsole 5.1.1\n",
"QtPy 1.11.2\n",
"readme-renderer 29.0\n",
"requests 2.26.0\n",
"requests-toolbelt 0.9.1\n",
"retrying 1.3.3\n",
"rfc3986 1.5.0\n",
"s3transfer 0.1.13\n",
"scikit-image 0.17.2\n",
"scikit-learn 0.20.1\n",
"scipy 1.7.1\n",
"seaborn 0.9.0\n",
"SecretStorage 3.3.1\n",
"Send2Trash 1.8.0\n",
"service-identity 21.1.0\n",
"setuptools 58.0.4\n",
"six 1.16.0\n",
"skillsnetwork 0.15.1\n",
"SQLAlchemy 1.3.9\n",
"sqlparse 0.4.2\n",
"statsmodels 0.12.0\n",
"systemml 1.2.0\n",
"tenacity 8.0.1\n",
"tensorboard 1.14.0\n",
"tensorflow 1.14.0\n",
"tensorflow-estimator 1.14.0\n",
"tensorflow-object-detection-api 0.1.1\n",
"termcolor 1.1.0\n",
"terminado 0.12.1\n",
"testpath 0.5.0\n",
"tifffile 2020.6.3\n",
"toolz 0.11.1\n",
"torch 1.5.0\n",
"torchvision 0.2.1\n",
"tornado 6.1\n",
"tqdm 4.60.0\n",
"traitlets 5.1.0\n",
"twine 3.4.2\n",
"Twisted 21.7.0\n",
"txaio 21.2.1\n",
"typing-extensions 3.10.0.2\n",
"urllib3 1.26.7\n",
"watson-developer-cloud 1.4.1\n",
"wcwidth 0.2.5\n",
"webencodings 0.5.1\n",
"Werkzeug 2.0.1\n",
"wget 3.2\n",
"wheel 0.37.0\n",
"widgetsnbextension 3.4.2\n",
"wrapt 1.12.1\n",
"xlrd 1.2.0\n",
"zipp 3.5.0\n",
"zope.interface 5.4.0\n"
]
}
],
"source": [
"!pip list"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "05405fb9-3d9f-4050-b470-f7d265795725",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# !jupyter labextension list"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cbc0e745-c087-4255-8bfb-eef2abfbbcdd",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# notebook hangs if I run the following command \n",
"JupyterDash.infer_jupyter_proxy_config()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "79ef755e-5a9c-421a-b092-64007db78ef6",
"metadata": {},
"outputs": [],
"source": [
"# needs to be run again in a separate cell due to a jupyterdash bug\n",
"JupyterDash.infer_jupyter_proxy_config()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "d42cf460-c547-4b0a-9b3b-165a5e1a331a",
"metadata": {},
"outputs": [],
"source": [
"spacex_df = pd.read_csv('https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBM-DS0321EN-SkillsNetwork/datasets/spacex_launch_dash.csv')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "d082480c-f1ed-4dd7-9b4c-1f69a4b9ef5f",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"650\"\n",
" src=\"http://localhost:8050/\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7f2aa3683790>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# skeleton Dash app to be completed in this lab, downloaded from:\n",
"# https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBM-DS0321EN-SkillsNetwork/labs/module_3/spacex_dash_app.py\n",
"# redundant lines commented out\n",
"\n",
"# Import required libraries\n",
"# import pandas as pd\n",
"# import dash\n",
"# import dash_html_components as html\n",
"# import dash_core_components as dcc\n",
"# from dash.dependencies import Input, Output\n",
"import plotly.express as px\n",
"\n",
"# Read the airline data into pandas dataframe\n",
"# spacex_df = pd.read_csv(\"spacex_launch_dash.csv\")\n",
"max_payload = spacex_df['Payload Mass (kg)'].max()\n",
"min_payload = spacex_df['Payload Mass (kg)'].min()\n",
"\n",
"# Create a dash application\n",
"# app = dash.Dash(__name__) # commented out as we are using JupyterDash instead of dash.Dash\n",
"app = JupyterDash(__name__)\n",
"\n",
"# Create an app layout\n",
"app.layout = html.Div(children=[html.H1('SpaceX Launch Records Dashboard',\n",
" style={'textAlign': 'center', 'color': '#503D36',\n",
" 'font-size': 40}),\n",
" # TASK 1: Add a dropdown list to enable Launch Site selection\n",
" # The default select value is for ALL sites\n",
" # dcc.Dropdown(id='site-dropdown',...)\n",
" dcc.Dropdown(id='site-dropdown',\n",
" options=[\n",
" {'label': 'All Sites', 'value': 'ALL'},\n",
" {'label': 'CCAFS LC-40', 'value': 'CCAFS LC-40'},\n",
" {'label': 'VAFB SLC-4E', 'value': 'VAFB SLC-4E'},\n",
" {'label': 'KSC LC-39A', 'value': 'KSC LC-39A'},\n",
" {'label': 'CCAFS SLC-40', 'value': 'CCAFS SLC-40'}\n",
" ],\n",
" value='ALL',\n",
" placeholder='Select a Launch Site here',\n",
" searchable=True\n",
" # style={'width':'80%','padding':'3px','font-size':'20px','text-align-last':'center'}\n",
" ),\n",
" html.Br(),\n",
"\n",
" # TASK 2: Add a pie chart to show the total successful launches count for all sites\n",
" # If a specific launch site was selected, show the Success vs. Failed counts for the site\n",
" html.Div(dcc.Graph(id='success-pie-chart')),\n",
" html.Br(),\n",
"\n",
" html.P(\"Payload range (Kg):\"),\n",
" # TASK 3: Add a slider to select payload range\n",
" #dcc.RangeSlider(id='payload-slider',...)\n",
" dcc.RangeSlider(id='payload-slider',\n",
" min=0,\n",
" max=10000,\n",
" step=1000,\n",
" value=[min_payload, max_payload]\n",
" ),\n",
"\n",
" # TASK 4: Add a scatter chart to show the correlation between payload and launch success\n",
" html.Div(dcc.Graph(id='success-payload-scatter-chart')),\n",
" ])\n",
"\n",
"# TASK 2:\n",
"# Add a callback function for `site-dropdown` as input, `success-pie-chart` as output\n",
"@app.callback(Output(component_id='success-pie-chart', component_property='figure'),\n",
" Input(component_id='site-dropdown', component_property='value'))\n",
"def get_pie_chart(entered_site):\n",
" filtered_df = spacex_df\n",
" if entered_site == 'ALL':\n",
" fig = px.pie(filtered_df, values='class', \n",
" names='Launch Site', \n",
" title='Success Count for all launch sites')\n",
" return fig\n",
" else:\n",
" # return the outcomes piechart for a selected site\n",
" filtered_df=spacex_df[spacex_df['Launch Site']== entered_site]\n",
" filtered_df=filtered_df.groupby(['Launch Site','class']).size().reset_index(name='class count')\n",
" fig=px.pie(filtered_df,values='class count',names='class',title=f\"Total Success Launches for site {entered_site}\")\n",
" return fig\n",
"\n",
"# TASK 4:\n",
"# Add a callback function for `site-dropdown` and `payload-slider` as inputs, `success-payload-scatter-chart` as output\n",
"@app.callback(Output(component_id='success-payload-scatter-chart',component_property='figure'),\n",
" [Input(component_id='site-dropdown',component_property='value'),\n",
" Input(component_id='payload-slider',component_property='value')])\n",
"def scatter(entered_site,payload):\n",
" filtered_df = spacex_df[spacex_df['Payload Mass (kg)'].between(payload[0],payload[1])]\n",
" # thought reusing filtered_df may cause issues, but tried it out of curiosity and it seems to be working fine\n",
" \n",
" if entered_site=='ALL':\n",
" fig=px.scatter(filtered_df,x='Payload Mass (kg)',y='class',color='Booster Version Category',title='Success count on Payload mass for all sites')\n",
" return fig\n",
" else:\n",
" fig=px.scatter(filtered_df[filtered_df['Launch Site']==entered_site],x='Payload Mass (kg)',y='class',color='Booster Version Category',title=f\"Success count on Payload mass for site {entered_site}\")\n",
" return fig\n",
"\n",
"# Run the app\n",
"if __name__ == '__main__':\n",
" app.run_server(mode='inline', host='localhost')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6ebdb318-64ec-472f-abc9-77da57adbbb1",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python",
"language": "python",
"name": "conda-env-python-py"
},
"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.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
@brt-h
Copy link
Author

brt-h commented Oct 13, 2021

I have been informed by an instructor that the provided cloud environment has a configuration problem preventing jupyter_dash from working, would have to set up local environment or try another cloud environment ie google colab

@brt-h
Copy link
Author

brt-h commented Oct 28, 2021

Check it out, this dash app has been deployed to heroku:
https://ibm-applied-data-science-capst.herokuapp.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment