{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A comparison to the below\n",
    "\n",
    "https://github.com/tirthajyoti/Interactive_Machine_Learning/blob/master/Interactive%20ML-Regression.ipynb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from reactpy import Reactive, Interact, Plot\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib widget\n",
    "\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.preprocessing import PolynomialFeatures\n",
    "from sklearn.linear_model import LassoCV\n",
    "from sklearn.linear_model import RidgeCV\n",
    "from sklearn.linear_model import LinearRegression\n",
    "from sklearn.pipeline import make_pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "r = Reactive(lazy_eval=False)\n",
    "r.update(get_ipython().user_ns)\n",
    "get_ipython().user_ns =  r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "806090b4dcef4f64a7c07d600ecd105d",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(Dropdown(description='value', options={'Low (50 samples)': 50, 'High (200 samples)': 200…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "6452718ba88e4be7a1f174bc7bcf3616",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(IntSlider(value=-3, description='value', max=0, min=-5), Output()), _dom_classes=('widge…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "48800e7e8ca14fbaa4dc7a09fa1c1c1e",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(IntSlider(value=2, description='value', max=5), Output()), _dom_classes=('widget-interac…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "2715c3fc6ea34594a87c7b99e78903db",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(IntSlider(value=2, description='value', max=5), Output()), _dom_classes=('widget-interac…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "5a080c0d54f244ce9f0f0c651aefa19b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(FloatSlider(value=0.5, description='value', max=1.0, min=0.1), Output()), _dom_classes=(…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "551b1ee1bc59468f8b23ed15e1781e84",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(FloatSlider(value=0.0, description='value', max=2.0, min=-2.0, step=0.5), Output()), _do…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "e2dc5ef670f4434eb6f165f969196ae8",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "N_samples = Interact('Samples', {'Low (50 samples)':50,'High (200 samples)':200})\n",
    "x_min = Interact('Min X', (-5,0,1))\n",
    "x_max = Interact('Max X', (0,5,1))\n",
    "noise_mag = Interact('Mag Noise', (0,5,1))\n",
    "noise_sd = Interact('Std. Noise', (0.1,1,0.1))\n",
    "noise_mean = Interact('Mean Noise', (-2,2,0.5))\n",
    "\n",
    "x1= r(lambda x_min, x_max, N_samples: np.linspace(x_min,x_max,N_samples*5))\n",
    "x = r(lambda x1, N_samples: np.random.choice(x1, size=N_samples))\n",
    "y = r(lambda x: 2*x-0.6*x**2+0.2*x**3+18*np.sin(x))\n",
    "y1 = r(lambda x1: 2*x1-0.6*x1**2+0.2*x1**3+18*np.sin(x1))\n",
    "yp = r(lambda y, noise_mag, noise_mean, noise_sd, N_samples: y+noise_mag*np.random.normal(\n",
    "    loc=noise_mean,scale=noise_sd,size=N_samples))\n",
    "\n",
    "def plot(ax,x,yp,x1,y1):\n",
    "    ax.plot(x1,y1,c='k',lw=2)\n",
    "    ax.scatter(x,yp,edgecolors='k',c='yellow',s=60)\n",
    "    ax.grid(True)    \n",
    "\n",
    "p = Plot(plot)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "lasso_eps = 0.01\n",
    "lasso_nalpha=20\n",
    "lasso_iter=3000\n",
    "ridge_alphas = (0.001,0.01,0.1,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "0627d0b2cbe2491d9161ffa444cc8347",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(Dropdown(description='value', options=('Linear regression', 'LASSO with CV', 'Ridge with…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "ba83c2c9384742499cbf82ca9b4835ea",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(IntSlider(value=50, description='value', max=99, min=10, step=5), Output()), _dom_classe…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "37f8478837624c66bc99f4664f5eca88",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(IntSlider(value=5, description='value', max=10, min=1), Output()), _dom_classes=('widget…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "d0bf4cb619b84ee7bad7ba9d5e093ec2",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "model_type = Interact('Model', ['Linear regression','LASSO with CV', 'Ridge with CV'])\n",
    "test_size = Interact('Test Size %', (10,99,5))\n",
    "degree = Interact('Degree', (1,10,1))\n",
    "\n",
    "split = r(lambda x,y,test_size: train_test_split(\n",
    "    x,y,test_size=test_size*0.01,random_state=55))\n",
    "X_train = r(lambda split: split[0].reshape(-1,1))\n",
    "X_test  = r(lambda split: split[1].reshape(-1,1))\n",
    "y_train = r(lambda split: split[2])\n",
    "y_test  = r(lambda split: split[3])\n",
    "\n",
    "def get_model(X_train, y_train, model_type, degree, ):\n",
    "    if (model_type=='Linear regression'):\n",
    "        model = make_pipeline(PolynomialFeatures(degree,interaction_only=False), \n",
    "                          LinearRegression(normalize=True))\n",
    "    if (model_type=='LASSO with CV'):    \n",
    "        model = make_pipeline(PolynomialFeatures(degree,interaction_only=False), \n",
    "                              LassoCV(eps=lasso_eps,n_alphas=lasso_nalpha,\n",
    "                                        max_iter=lasso_iter,normalize=True,cv=5))        \n",
    "    if (model_type=='Ridge with CV'):    \n",
    "        model = make_pipeline(PolynomialFeatures(degree,interaction_only=False), \n",
    "                              RidgeCV(alphas=ridge_alphas,normalize=True,cv=5))\n",
    "    model.fit(X_train,y_train)\n",
    "    return model\n",
    "\n",
    "model = r(get_model)\n",
    "train_pred  = r(lambda model, X_train: model.predict(X_train))\n",
    "train_score = r(lambda model, X_train, y_train: model.score(X_train,y_train))\n",
    "test_pred   = r(lambda model, X_test: model.predict(X_test))\n",
    "test_score  = r(lambda model, X_test, y_test: model.score(X_test,y_test))\n",
    "RMSE_test   = r(lambda test_pred, y_test: np.sqrt(np.mean(np.square(test_pred-y_test))))\n",
    "RMSE_train  = r(lambda train_pred, y_train: np.sqrt(np.mean(np.square(train_pred-y_train))))\n",
    "\n",
    "fig,(ax1, ax2) = plt.subplots(1, 2, figsize=(10,6))\n",
    "ax1.set_xlim(-3,3)\n",
    "ax1.set_ylim(-30,30)\n",
    "ax2.set_xlim(-3,3)\n",
    "ax2.set_ylim(-30,30)\n",
    "\n",
    "def plot1(ax, test_score, X_test, y_test, test_pred):\n",
    "    ax.set_title(\"Test set performance\\nTest score: %.3f\"%(test_score),fontsize=16)\n",
    "    ax.set_xlabel(\"X-test\",fontsize=13)\n",
    "    ax.set_ylabel(\"y-test\",fontsize=13)\n",
    "    ax.scatter(X_test,y_test,edgecolors='k',c='blue',s=60)\n",
    "    ax.scatter(X_test,test_pred,edgecolors='k',c='yellow',s=60)\n",
    "    ax.grid(True)\n",
    "    ax.legend(['Actual test values','Predicted values'])\n",
    "    \n",
    "def plot2(ax, train_score, X_train, y_train, train_pred):\n",
    "    ax.set_title(\"Training set performance\\nTraining score: %.3f\"%(train_score),fontsize=16)\n",
    "    ax.set_xlabel(\"X-train\",fontsize=13)\n",
    "    ax.set_ylabel(\"y-train\",fontsize=13)\n",
    "    ax.scatter(X_train,y_train,c='blue')\n",
    "    ax.scatter(X_train,train_pred,c='yellow')\n",
    "    ax.grid(True)\n",
    "    ax.legend(['Actual training values','Fitted values'])\n",
    "    \n",
    "p2 = Plot(plot1, ax=ax1)\n",
    "p3 = Plot(plot2, ax=ax2)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "PyQ 3",
   "language": "python",
   "name": "pyq_3"
  },
  "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.9"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {
     "04342548acf744ad994c6db00f2959e1": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "IntSliderModel",
      "state": {
       "description": "Test Size %",
       "layout": "IPY_MODEL_1bf12ddd5e6244b6bd438b88c7612ab4",
       "max": 99,
       "min": 10,
       "step": 5,
       "style": "IPY_MODEL_14787dcfbcaf4bc9a75e9bfc84922ee6",
       "value": 50
      }
     },
     "0627d0b2cbe2491d9161ffa444cc8347": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "VBoxModel",
      "state": {
       "_dom_classes": [
        "widget-interact"
       ],
       "children": [
        "IPY_MODEL_52a67736eedc40d39b75ca210ec55856",
        "IPY_MODEL_0f3a1103125748a0bc0c3d87f31522b5"
       ],
       "layout": "IPY_MODEL_8546af6c4222465fa22d3b3a6be6747a"
      }
     },
     "0b2b224e9d934d95ad5707a22615a294": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "0f3a1103125748a0bc0c3d87f31522b5": {
      "model_module": "@jupyter-widgets/output",
      "model_module_version": "1.0.0",
      "model_name": "OutputModel",
      "state": {
       "layout": "IPY_MODEL_0b2b224e9d934d95ad5707a22615a294"
      }
     },
     "0fa40f66de604717adbf4a7eaa87bb44": {
      "model_module": "@jupyter-widgets/output",
      "model_module_version": "1.0.0",
      "model_name": "OutputModel",
      "state": {
       "layout": "IPY_MODEL_d8fd246f2184490d8178cb6c315bb061"
      }
     },
     "1214c990f6284ffaab526eb863238952": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "12467107ab7041868111f564f3d5279b": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "14430c91706544b6a5ff3b5e4c35cac0": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "14787dcfbcaf4bc9a75e9bfc84922ee6": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "SliderStyleModel",
      "state": {
       "description_width": ""
      }
     },
     "14b787c3dffc4e4e93e4fb51bc34c701": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "16df789706954459a4f9b6f8d6ddd5d7": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "19644838380a476bbe627d4085bb8dba": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "SliderStyleModel",
      "state": {
       "description_width": ""
      }
     },
     "1bf12ddd5e6244b6bd438b88c7612ab4": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "24c5e8d596b94126a30adcff0622052b": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "2715c3fc6ea34594a87c7b99e78903db": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "VBoxModel",
      "state": {
       "_dom_classes": [
        "widget-interact"
       ],
       "children": [
        "IPY_MODEL_7bb53d885e224d76ba240b767546c32f",
        "IPY_MODEL_d0987a24e635494bba03bb27bc57f657"
       ],
       "layout": "IPY_MODEL_6719f44d15fc4c1081c9eef0ece2834d"
      }
     },
     "309848a6b9e2434e97e6b04b7b98d50f": {
      "model_module": "@jupyter-widgets/output",
      "model_module_version": "1.0.0",
      "model_name": "OutputModel",
      "state": {
       "layout": "IPY_MODEL_9bb20e6ffbe6465c9ee6a142af1dd5dd"
      }
     },
     "30afdaf5d1d24e76967e0ce81f31e5d6": {
      "model_module": "@jupyter-widgets/output",
      "model_module_version": "1.0.0",
      "model_name": "OutputModel",
      "state": {
       "layout": "IPY_MODEL_5aed2e19e5de4418a9b624b3741b4962"
      }
     },
     "3646215d2d284159b16d364a678b233e": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "37f8478837624c66bc99f4664f5eca88": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "VBoxModel",
      "state": {
       "_dom_classes": [
        "widget-interact"
       ],
       "children": [
        "IPY_MODEL_d6e60b91cbfa4714b7fedea158f1e61f",
        "IPY_MODEL_309848a6b9e2434e97e6b04b7b98d50f"
       ],
       "layout": "IPY_MODEL_9c789b41cf2a4814b1ff3e9b715a9a38"
      }
     },
     "41274f03923f4f2199951f40ef83937a": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "428d88552688433483fbf52a0e91962a": {
      "model_module": "@jupyter-widgets/output",
      "model_module_version": "1.0.0",
      "model_name": "OutputModel",
      "state": {
       "layout": "IPY_MODEL_611fdadb90834bbbb214fc249772992c"
      }
     },
     "429c51e47a2e4f5f9509c9b35bc96ea0": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "FloatSliderModel",
      "state": {
       "description": "Mean Noise",
       "layout": "IPY_MODEL_8979e92d61214d8f8fb0b288012283fe",
       "max": 2,
       "min": -2,
       "step": 0.5,
       "style": "IPY_MODEL_7f053ec44a0d4523a72b1697db7b546f"
      }
     },
     "4661f390b6a6410d9a90639a41cfe9d3": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "DescriptionStyleModel",
      "state": {
       "description_width": ""
      }
     },
     "48800e7e8ca14fbaa4dc7a09fa1c1c1e": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "VBoxModel",
      "state": {
       "_dom_classes": [
        "widget-interact"
       ],
       "children": [
        "IPY_MODEL_a2415eb17019416aa51687879e8065ac",
        "IPY_MODEL_0fa40f66de604717adbf4a7eaa87bb44"
       ],
       "layout": "IPY_MODEL_14430c91706544b6a5ff3b5e4c35cac0"
      }
     },
     "4f022ed82f2141a597931d10546260b1": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "SliderStyleModel",
      "state": {
       "description_width": ""
      }
     },
     "523513f487474c35806a65d8c0b7c325": {
      "model_module": "@jupyter-widgets/output",
      "model_module_version": "1.0.0",
      "model_name": "OutputModel",
      "state": {
       "layout": "IPY_MODEL_14b787c3dffc4e4e93e4fb51bc34c701"
      }
     },
     "52a67736eedc40d39b75ca210ec55856": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "DropdownModel",
      "state": {
       "_options_labels": [
        "Linear regression",
        "LASSO with CV",
        "Ridge with CV"
       ],
       "description": "Model",
       "index": 0,
       "layout": "IPY_MODEL_82c1a259ef2a4075a9ca9408b64decf5",
       "style": "IPY_MODEL_4661f390b6a6410d9a90639a41cfe9d3"
      }
     },
     "551b1ee1bc59468f8b23ed15e1781e84": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "VBoxModel",
      "state": {
       "_dom_classes": [
        "widget-interact"
       ],
       "children": [
        "IPY_MODEL_429c51e47a2e4f5f9509c9b35bc96ea0",
        "IPY_MODEL_f9f783a4d3044a3191ffe57f764bdccc"
       ],
       "layout": "IPY_MODEL_8218d2b680b540a3b8f794b673fc8fe9"
      }
     },
     "5a080c0d54f244ce9f0f0c651aefa19b": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "VBoxModel",
      "state": {
       "_dom_classes": [
        "widget-interact"
       ],
       "children": [
        "IPY_MODEL_a8aa2ec1df5f44679b279167eefff630",
        "IPY_MODEL_523513f487474c35806a65d8c0b7c325"
       ],
       "layout": "IPY_MODEL_70e0ad80b2034768a8dfcdc7de044a39"
      }
     },
     "5ad89aa03e5d4fbb957623cbcb53c28b": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "DropdownModel",
      "state": {
       "_options_labels": [
        "Low (50 samples)",
        "High (200 samples)"
       ],
       "description": "Samples",
       "index": 0,
       "layout": "IPY_MODEL_3646215d2d284159b16d364a678b233e",
       "style": "IPY_MODEL_f8b2d1726f8f434bb794246eab3ff927"
      }
     },
     "5aed2e19e5de4418a9b624b3741b4962": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "5c1eaf055290452c99cee607b957df55": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "611fdadb90834bbbb214fc249772992c": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "6452718ba88e4be7a1f174bc7bcf3616": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "VBoxModel",
      "state": {
       "_dom_classes": [
        "widget-interact"
       ],
       "children": [
        "IPY_MODEL_f65d73272eb44416b28416da4f56b8cd",
        "IPY_MODEL_428d88552688433483fbf52a0e91962a"
       ],
       "layout": "IPY_MODEL_edf680234f3c486cbda894856fd5a483"
      }
     },
     "66e6382c309a4efc87d3938a1d871445": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "6719f44d15fc4c1081c9eef0ece2834d": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "67d8ffe694f64e1c8e50d429d68761e6": {
      "model_module": "jupyter-matplotlib",
      "model_module_version": "^0.7.4",
      "model_name": "ToolbarModel",
      "state": {
       "layout": "IPY_MODEL_5c1eaf055290452c99cee607b957df55",
       "toolitems": [
        [
         "Home",
         "Reset original view",
         "home",
         "home"
        ],
        [
         "Back",
         "Back to previous view",
         "arrow-left",
         "back"
        ],
        [
         "Forward",
         "Forward to next view",
         "arrow-right",
         "forward"
        ],
        [
         "Pan",
         "Pan axes with left mouse, zoom with right",
         "arrows",
         "pan"
        ],
        [
         "Zoom",
         "Zoom to rectangle",
         "square-o",
         "zoom"
        ],
        [
         "Download",
         "Download plot",
         "floppy-o",
         "save_figure"
        ]
       ]
      }
     },
     "70e0ad80b2034768a8dfcdc7de044a39": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "727519533ed6424290c4c00417c0b07f": {
      "model_module": "jupyter-matplotlib",
      "model_module_version": "^0.7.4",
      "model_name": "ToolbarModel",
      "state": {
       "layout": "IPY_MODEL_24c5e8d596b94126a30adcff0622052b",
       "toolitems": [
        [
         "Home",
         "Reset original view",
         "home",
         "home"
        ],
        [
         "Back",
         "Back to previous view",
         "arrow-left",
         "back"
        ],
        [
         "Forward",
         "Forward to next view",
         "arrow-right",
         "forward"
        ],
        [
         "Pan",
         "Pan axes with left mouse, zoom with right",
         "arrows",
         "pan"
        ],
        [
         "Zoom",
         "Zoom to rectangle",
         "square-o",
         "zoom"
        ],
        [
         "Download",
         "Download plot",
         "floppy-o",
         "save_figure"
        ]
       ]
      }
     },
     "7bb53d885e224d76ba240b767546c32f": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "IntSliderModel",
      "state": {
       "description": "Mag Noise",
       "layout": "IPY_MODEL_16df789706954459a4f9b6f8d6ddd5d7",
       "max": 5,
       "style": "IPY_MODEL_4f022ed82f2141a597931d10546260b1",
       "value": 2
      }
     },
     "7f053ec44a0d4523a72b1697db7b546f": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "SliderStyleModel",
      "state": {
       "description_width": ""
      }
     },
     "806090b4dcef4f64a7c07d600ecd105d": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "VBoxModel",
      "state": {
       "_dom_classes": [
        "widget-interact"
       ],
       "children": [
        "IPY_MODEL_5ad89aa03e5d4fbb957623cbcb53c28b",
        "IPY_MODEL_30afdaf5d1d24e76967e0ce81f31e5d6"
       ],
       "layout": "IPY_MODEL_edee014a6ded473aa30549642ed8b40c"
      }
     },
     "8218d2b680b540a3b8f794b673fc8fe9": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "82c1a259ef2a4075a9ca9408b64decf5": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "8546af6c4222465fa22d3b3a6be6747a": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "8979e92d61214d8f8fb0b288012283fe": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "906294d8519c45279f29e35b52cedf0b": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "9bb20e6ffbe6465c9ee6a142af1dd5dd": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "9c789b41cf2a4814b1ff3e9b715a9a38": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "a2415eb17019416aa51687879e8065ac": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "IntSliderModel",
      "state": {
       "description": "Max X",
       "layout": "IPY_MODEL_e5d6e98ff2624db689fb56a3e489b917",
       "max": 5,
       "style": "IPY_MODEL_fd7a93604d4d4bb9a9f72a1f98ca63cd",
       "value": 2
      }
     },
     "a8aa2ec1df5f44679b279167eefff630": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "FloatSliderModel",
      "state": {
       "description": "Std. Noise",
       "layout": "IPY_MODEL_1214c990f6284ffaab526eb863238952",
       "max": 1,
       "min": 0.1,
       "step": 0.1,
       "style": "IPY_MODEL_19644838380a476bbe627d4085bb8dba",
       "value": 0.5
      }
     },
     "ae4784b038f04fff85850fa7776010a4": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "ba83c2c9384742499cbf82ca9b4835ea": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "VBoxModel",
      "state": {
       "_dom_classes": [
        "widget-interact"
       ],
       "children": [
        "IPY_MODEL_04342548acf744ad994c6db00f2959e1",
        "IPY_MODEL_c8c45d7d34814122a7013381c503b1ff"
       ],
       "layout": "IPY_MODEL_e682d21ff8584d3ab03f97e822875c67"
      }
     },
     "bece90e4424c426a8dd52334e1e2d735": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "c8c45d7d34814122a7013381c503b1ff": {
      "model_module": "@jupyter-widgets/output",
      "model_module_version": "1.0.0",
      "model_name": "OutputModel",
      "state": {
       "layout": "IPY_MODEL_12467107ab7041868111f564f3d5279b"
      }
     },
     "cb5fb744016046b5bd2752ed4476277d": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "SliderStyleModel",
      "state": {
       "description_width": ""
      }
     },
     "cbfed7d7254d4417b4e7da03a22c3fdd": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "SliderStyleModel",
      "state": {
       "description_width": ""
      }
     },
     "d0987a24e635494bba03bb27bc57f657": {
      "model_module": "@jupyter-widgets/output",
      "model_module_version": "1.0.0",
      "model_name": "OutputModel",
      "state": {
       "layout": "IPY_MODEL_66e6382c309a4efc87d3938a1d871445"
      }
     },
     "d0bf4cb619b84ee7bad7ba9d5e093ec2": {
      "model_module": "jupyter-matplotlib",
      "model_module_version": "^0.7.4",
      "model_name": "MPLCanvasModel",
      "state": {
       "_cursor": "default",
       "_figure_label": "Figure 2",
       "_height": 600,
       "_width": 1000,
       "layout": "IPY_MODEL_ae4784b038f04fff85850fa7776010a4",
       "toolbar": "IPY_MODEL_727519533ed6424290c4c00417c0b07f",
       "toolbar_position": "left"
      }
     },
     "d6e60b91cbfa4714b7fedea158f1e61f": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "IntSliderModel",
      "state": {
       "description": "Degree",
       "layout": "IPY_MODEL_bece90e4424c426a8dd52334e1e2d735",
       "max": 10,
       "min": 1,
       "style": "IPY_MODEL_cb5fb744016046b5bd2752ed4476277d",
       "value": 5
      }
     },
     "d8fd246f2184490d8178cb6c315bb061": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "de5f14405efc45408ca8d280210a7b2d": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "e2dc5ef670f4434eb6f165f969196ae8": {
      "model_module": "jupyter-matplotlib",
      "model_module_version": "^0.7.4",
      "model_name": "MPLCanvasModel",
      "state": {
       "_cursor": "default",
       "_figure_label": "Figure 1",
       "_height": 480,
       "_width": 640,
       "layout": "IPY_MODEL_906294d8519c45279f29e35b52cedf0b",
       "toolbar": "IPY_MODEL_67d8ffe694f64e1c8e50d429d68761e6",
       "toolbar_position": "left"
      }
     },
     "e5d6e98ff2624db689fb56a3e489b917": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "e682d21ff8584d3ab03f97e822875c67": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "edee014a6ded473aa30549642ed8b40c": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "edf680234f3c486cbda894856fd5a483": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {}
     },
     "f65d73272eb44416b28416da4f56b8cd": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "IntSliderModel",
      "state": {
       "description": "Min X",
       "layout": "IPY_MODEL_de5f14405efc45408ca8d280210a7b2d",
       "max": 0,
       "min": -5,
       "style": "IPY_MODEL_cbfed7d7254d4417b4e7da03a22c3fdd",
       "value": -3
      }
     },
     "f8b2d1726f8f434bb794246eab3ff927": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "DescriptionStyleModel",
      "state": {
       "description_width": ""
      }
     },
     "f9f783a4d3044a3191ffe57f764bdccc": {
      "model_module": "@jupyter-widgets/output",
      "model_module_version": "1.0.0",
      "model_name": "OutputModel",
      "state": {
       "layout": "IPY_MODEL_41274f03923f4f2199951f40ef83937a"
      }
     },
     "fd7a93604d4d4bb9a9f72a1f98ca63cd": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "SliderStyleModel",
      "state": {
       "description_width": ""
      }
     }
    },
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}