| { |
| "cells": [ |
| { |
| "cell_type": "markdown", |
| "metadata": { |
| "collapsed": false, |
| "jupyter": { |
| "outputs_hidden": false |
| } |
| }, |
| "source": [ |
| "Uncomment and run the cell below if you are in a Google Colab environment. It will:\n", |
| "1. Mount google drive. You will be asked to authenticate and give permissions.\n", |
| "2. Change directory to google drive.\n", |
| "3. Make a directory \"hamilton-tutorials\"\n", |
| "4. Change directory to it.\n", |
| "5. Clone this repository to your google drive\n", |
| "6. Move your current directory to the hello_world example\n", |
| "7. Install requirements.\n", |
| "\n", |
| "This means that any modifications will be saved, and you won't lose them if you close your browser." |
| ] |
| }, |
| { |
| "cell_type": "code", |
| "execution_count": 2, |
| "metadata": { |
| "collapsed": false, |
| "jupyter": { |
| "outputs_hidden": false |
| }, |
| "pycharm": { |
| "name": "#%%\n" |
| } |
| }, |
| "outputs": [], |
| "source": [ |
| "## 1. Mount google drive\n", |
| "# from google.colab import drive\n", |
| "# drive.mount('/content/drive')\n", |
| "## 2. Change directory to google drive.\n", |
| "# %cd /content/drive/MyDrive\n", |
| "## 3. Make a directory \"hamilton-tutorials\"\n", |
| "# !mkdir hamilton-tutorials\n", |
| "## 4. Change directory to it.\n", |
| "# %cd hamilton-tutorials\n", |
| "## 5. Clone this repository to your google drive\n", |
| "# !git clone https://github.com/DAGWorks-Inc/hamilton/\n", |
| "## 6. Move your current directory to the hello_world example\n", |
| "# %cd hamilton/examples/hello_world\n", |
| "## 7. Install requirements.\n", |
| "# %pip install -r requirements.txt\n", |
| "# clear_output() # optionally clear outputs\n", |
| "# To check your current working directory you can type `!pwd` in a cell and run it." |
| ] |
| }, |
| { |
| "cell_type": "code", |
| "execution_count": 3, |
| "metadata": { |
| "collapsed": false, |
| "jupyter": { |
| "outputs_hidden": false |
| }, |
| "pycharm": { |
| "name": "#%%\n" |
| } |
| }, |
| "outputs": [], |
| "source": [ |
| "# Cell 2 - import modules to create part of the DAG from\n", |
| "# We use the autoreload extension that comes with ipython to automatically reload modules when\n", |
| "# the code in them changes.\n", |
| "\n", |
| "# import the jupyter extension\n", |
| "%load_ext autoreload\n", |
| "# set it to only reload the modules imported\n", |
| "%autoreload 1" |
| ] |
| }, |
| { |
| "cell_type": "code", |
| "execution_count": 4, |
| "metadata": { |
| "collapsed": false, |
| "jupyter": { |
| "outputs_hidden": false |
| }, |
| "pycharm": { |
| "name": "#%%\n" |
| } |
| }, |
| "outputs": [ |
| { |
| "name": "stderr", |
| "output_type": "stream", |
| "text": [ |
| "/Users/stefankrawczyk/.pyenv/versions/3.9.13/envs/temp-py39/lib/python3.9/site-packages/pyspark/pandas/__init__.py:50: UserWarning: 'PYARROW_IGNORE_TIMEZONE' environment variable was not set. It is required to set this environment variable to '1' in both driver and executor sides if you use pyarrow>=2.0.0. pandas-on-Spark will set it for you but it does not work if there is a Spark context already launched.\n", |
| " warnings.warn(\n" |
| ] |
| } |
| ], |
| "source": [ |
| "import polars as pl\n", |
| "\n", |
| "from hamilton import (\n", |
| " base,\n", |
| " driver,\n", |
| ")\n", |
| "from hamilton.function_modifiers import extract_columns\n", |
| "from hamilton.plugins import h_polars" |
| ] |
| }, |
| { |
| "cell_type": "code", |
| "execution_count": 5, |
| "metadata": { |
| "collapsed": false, |
| "jupyter": { |
| "outputs_hidden": false |
| }, |
| "pycharm": { |
| "name": "#%%\n" |
| } |
| }, |
| "outputs": [ |
| { |
| "name": "stdout", |
| "output_type": "stream", |
| "text": [ |
| "Writing spend_calculations.py\n" |
| ] |
| } |
| ], |
| "source": [ |
| "%%writefile spend_calculations.py\n", |
| "\n", |
| "import polars as pl\n", |
| "from hamilton.function_modifiers import extract_columns\n", |
| "\n", |
| "# We'll place the spend calculations into a new module\n", |
| "\n", |
| "@extract_columns(\"signups\", \"spend\")\n", |
| "def base_df(base_df_location: str) -> pl.DataFrame:\n", |
| " \"\"\"Loads base dataframe of data.\n", |
| "\n", |
| " :param base_df_location: just showing that we could load this from a file...\n", |
| " :return:\n", |
| " \"\"\"\n", |
| " return pl.DataFrame(\n", |
| " {\n", |
| " \"signups\": pl.Series([1, 10, 50, 100, 200, 400]),\n", |
| " \"spend\": pl.Series([10, 10, 20, 40, 40, 50]),\n", |
| " }\n", |
| " )\n", |
| "\n", |
| "def avg_3wk_spend(spend: pl.Series) -> pl.Series:\n", |
| " \"\"\"Rolling 3 week average spend.\"\"\"\n", |
| " return spend.rolling_mean(3)\n", |
| "\n", |
| "def spend_per_signup(spend: pl.Series, signups: pl.Series) -> pl.Series:\n", |
| " \"\"\"The cost per signup in relation to spend.\"\"\"\n", |
| " return spend / signups\n", |
| "\n", |
| "def spend_mean(spend: pl.Series) -> float:\n", |
| " \"\"\"Shows function creating a scalar. In this case it computes the mean of the entire column.\"\"\"\n", |
| " return spend.mean()\n", |
| "\n", |
| "def spend_zero_mean(spend: pl.Series, spend_mean: float) -> pl.Series:\n", |
| " \"\"\"Shows function that takes a scalar. In this case to zero mean spend.\"\"\"\n", |
| " return spend - spend_mean\n", |
| "\n", |
| "def spend_std_dev(spend: pl.Series) -> float:\n", |
| " \"\"\"Function that computes the standard deviation of the spend column.\"\"\"\n", |
| " return spend.std()\n", |
| "\n", |
| "def spend_zero_mean_unit_variance(spend_zero_mean: pl.Series, spend_std_dev: float) -> pl.Series:\n", |
| " \"\"\"Function showing one way to make spend have zero mean and unit variance.\"\"\"\n", |
| " return spend_zero_mean / spend_std_dev" |
| ] |
| }, |
| { |
| "cell_type": "code", |
| "execution_count": 6, |
| "metadata": { |
| "collapsed": false, |
| "jupyter": { |
| "outputs_hidden": false |
| }, |
| "pycharm": { |
| "name": "#%%\n" |
| } |
| }, |
| "outputs": [ |
| { |
| "name": "stderr", |
| "output_type": "stream", |
| "text": [ |
| "Note: Hamilton collects completely anonymous data about usage. This will help us improve Hamilton over time. See https://github.com/dagworks-inc/hamilton#usage-analytics--data-privacy for details.\n" |
| ] |
| } |
| ], |
| "source": [ |
| "%aimport spend_calculations\n", |
| "\n", |
| "# Set up the driver, input and output columns\n", |
| "\n", |
| "config = {\n", |
| " \"base_df_location\": \"dummy_value\",\n", |
| "}\n", |
| "adapter = base.SimplePythonGraphAdapter(result_builder=h_polars.PolarsDataFrameResult())\n", |
| "dr = driver.Driver(config, spend_calculations, adapter=adapter)\n", |
| "output_columns = [\n", |
| " \"spend\",\n", |
| " \"signups\",\n", |
| " \"avg_3wk_spend\",\n", |
| " \"spend_per_signup\",\n", |
| " \"spend_zero_mean_unit_variance\",\n", |
| "]" |
| ] |
| }, |
| { |
| "cell_type": "code", |
| "execution_count": 7, |
| "metadata": { |
| "collapsed": false, |
| "jupyter": { |
| "outputs_hidden": false |
| }, |
| "pycharm": { |
| "name": "#%%\n" |
| } |
| }, |
| "outputs": [ |
| { |
| "name": "stdout", |
| "output_type": "stream", |
| "text": [ |
| "shape: (6, 5)\n", |
| "┌───────┬─────────┬───────────────┬──────────────────┬───────────────────────────────┐\n", |
| "│ spend ┆ signups ┆ avg_3wk_spend ┆ spend_per_signup ┆ spend_zero_mean_unit_variance │\n", |
| "│ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", |
| "│ i64 ┆ i64 ┆ f64 ┆ f64 ┆ f64 │\n", |
| "╞═══════╪═════════╪═══════════════╪══════════════════╪═══════════════════════════════╡\n", |
| "│ 10 ┆ 1 ┆ null ┆ 10.0 ┆ -1.064405 │\n", |
| "│ 10 ┆ 10 ┆ null ┆ 1.0 ┆ -1.064405 │\n", |
| "│ 20 ┆ 50 ┆ 13.333333 ┆ 0.4 ┆ -0.483821 │\n", |
| "│ 40 ┆ 100 ┆ 23.333333 ┆ 0.4 ┆ 0.677349 │\n", |
| "│ 40 ┆ 200 ┆ 33.333333 ┆ 0.2 ┆ 0.677349 │\n", |
| "│ 50 ┆ 400 ┆ 43.333333 ┆ 0.125 ┆ 1.257934 │\n", |
| "└───────┴─────────┴───────────────┴──────────────────┴───────────────────────────────┘\n" |
| ] |
| }, |
| { |
| "data": { |
| "image/svg+xml": [ |
| "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n", |
| "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n", |
| " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n", |
| "<!-- Generated by graphviz version 8.0.5 (20230430.1635)\n", |
| " -->\n", |
| "<!-- Pages: 1 -->\n", |
| "<svg width=\"453pt\" height=\"404pt\"\n", |
| " viewBox=\"0.00 0.00 453.00 404.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", |
| "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 400)\">\n", |
| "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-400 449,-400 449,4 -4,4\"/>\n", |
| "<!-- spend -->\n", |
| "<g id=\"node1\" class=\"node\">\n", |
| "<title>spend</title>\n", |
| "<polygon fill=\"none\" stroke=\"black\" points=\"238.88,-252 184.88,-252 184.88,-216 238.88,-216 238.88,-252\"/>\n", |
| "<text text-anchor=\"middle\" x=\"211.88\" y=\"-228.95\" font-family=\"Times,serif\" font-size=\"14.00\">spend</text>\n", |
| "</g>\n", |
| "<!-- avg_3wk_spend -->\n", |
| "<g id=\"node3\" class=\"node\">\n", |
| "<title>avg_3wk_spend</title>\n", |
| "<polygon fill=\"none\" stroke=\"black\" points=\"103.75,-180 0,-180 0,-144 103.75,-144 103.75,-180\"/>\n", |
| "<text text-anchor=\"middle\" x=\"51.88\" y=\"-156.95\" font-family=\"Times,serif\" font-size=\"14.00\">avg_3wk_spend</text>\n", |
| "</g>\n", |
| "<!-- spend->avg_3wk_spend -->\n", |
| "<g id=\"edge4\" class=\"edge\">\n", |
| "<title>spend->avg_3wk_spend</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M184.73,-221.13C162.02,-211.19 129.03,-196.75 101.6,-184.75\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"103.34,-181.26 92.78,-180.46 100.53,-187.67 103.34,-181.26\"/>\n", |
| "</g>\n", |
| "<!-- spend_std_dev -->\n", |
| "<g id=\"node5\" class=\"node\">\n", |
| "<title>spend_std_dev</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"92.88\" cy=\"-90\" rx=\"65.68\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"92.88\" y=\"-84.95\" font-family=\"Times,serif\" font-size=\"14.00\">spend_std_dev</text>\n", |
| "</g>\n", |
| "<!-- spend->spend_std_dev -->\n", |
| "<g id=\"edge6\" class=\"edge\">\n", |
| "<title>spend->spend_std_dev</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M197.28,-215.59C176.36,-190.62 137.72,-144.52 113.77,-115.94\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"115.95,-114.09 106.85,-108.67 110.59,-118.58 115.95,-114.09\"/>\n", |
| "</g>\n", |
| "<!-- spend_zero_mean -->\n", |
| "<g id=\"node6\" class=\"node\">\n", |
| "<title>spend_zero_mean</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"254.88\" cy=\"-90\" rx=\"77.97\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"254.88\" y=\"-84.95\" font-family=\"Times,serif\" font-size=\"14.00\">spend_zero_mean</text>\n", |
| "</g>\n", |
| "<!-- spend->spend_zero_mean -->\n", |
| "<g id=\"edge7\" class=\"edge\">\n", |
| "<title>spend->spend_zero_mean</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M200.52,-215.58C190.03,-197.12 177.63,-167.46 188.88,-144 194.73,-131.78 204.93,-121.49 215.58,-113.33\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"217.42,-115.61 223.55,-106.97 213.37,-109.9 217.42,-115.61\"/>\n", |
| "</g>\n", |
| "<!-- spend_mean -->\n", |
| "<g id=\"node9\" class=\"node\">\n", |
| "<title>spend_mean</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"254.88\" cy=\"-162\" rx=\"57.49\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"254.88\" y=\"-156.95\" font-family=\"Times,serif\" font-size=\"14.00\">spend_mean</text>\n", |
| "</g>\n", |
| "<!-- spend->spend_mean -->\n", |
| "<g id=\"edge10\" class=\"edge\">\n", |
| "<title>spend->spend_mean</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M222.5,-215.7C227.4,-207.73 233.31,-198.1 238.74,-189.26\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"242.12,-191.46 244.37,-181.1 236.15,-187.79 242.12,-191.46\"/>\n", |
| "</g>\n", |
| "<!-- spend_per_signup -->\n", |
| "<g id=\"node10\" class=\"node\">\n", |
| "<title>spend_per_signup</title>\n", |
| "<polygon fill=\"none\" stroke=\"black\" points=\"445,-180 330.75,-180 330.75,-144 445,-144 445,-180\"/>\n", |
| "<text text-anchor=\"middle\" x=\"387.88\" y=\"-156.95\" font-family=\"Times,serif\" font-size=\"14.00\">spend_per_signup</text>\n", |
| "</g>\n", |
| "<!-- spend->spend_per_signup -->\n", |
| "<g id=\"edge11\" class=\"edge\">\n", |
| "<title>spend->spend_per_signup</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M239.38,-222.06C264.67,-212 302.9,-196.8 334.24,-184.33\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"335.14,-187.34 343.14,-180.39 332.56,-180.84 335.14,-187.34\"/>\n", |
| "</g>\n", |
| "<!-- spend_zero_mean_unit_variance -->\n", |
| "<g id=\"node2\" class=\"node\">\n", |
| "<title>spend_zero_mean_unit_variance</title>\n", |
| "<polygon fill=\"none\" stroke=\"black\" points=\"271.12,-36 76.62,-36 76.62,0 271.12,0 271.12,-36\"/>\n", |
| "<text text-anchor=\"middle\" x=\"173.88\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">spend_zero_mean_unit_variance</text>\n", |
| "</g>\n", |
| "<!-- signups -->\n", |
| "<g id=\"node4\" class=\"node\">\n", |
| "<title>signups</title>\n", |
| "<polygon fill=\"none\" stroke=\"black\" points=\"365.5,-252 308.25,-252 308.25,-216 365.5,-216 365.5,-252\"/>\n", |
| "<text text-anchor=\"middle\" x=\"336.88\" y=\"-228.95\" font-family=\"Times,serif\" font-size=\"14.00\">signups</text>\n", |
| "</g>\n", |
| "<!-- signups->spend_per_signup -->\n", |
| "<g id=\"edge12\" class=\"edge\">\n", |
| "<title>signups->spend_per_signup</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M349.48,-215.7C355.35,-207.64 362.45,-197.89 368.94,-188.98\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"372.35,-191.25 375.41,-181.1 366.7,-187.13 372.35,-191.25\"/>\n", |
| "</g>\n", |
| "<!-- spend_std_dev->spend_zero_mean_unit_variance -->\n", |
| "<g id=\"edge3\" class=\"edge\">\n", |
| "<title>spend_std_dev->spend_zero_mean_unit_variance</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M112.07,-72.41C122.06,-63.78 134.47,-53.05 145.54,-43.48\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"147.41,-45.63 152.69,-36.45 142.83,-40.34 147.41,-45.63\"/>\n", |
| "</g>\n", |
| "<!-- spend_zero_mean->spend_zero_mean_unit_variance -->\n", |
| "<g id=\"edge2\" class=\"edge\">\n", |
| "<title>spend_zero_mean->spend_zero_mean_unit_variance</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M235.68,-72.41C225.69,-63.78 213.28,-53.05 202.21,-43.48\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"204.92,-40.34 195.06,-36.45 200.34,-45.63 204.92,-40.34\"/>\n", |
| "</g>\n", |
| "<!-- base_df -->\n", |
| "<g id=\"node7\" class=\"node\">\n", |
| "<title>base_df</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"248.88\" cy=\"-306\" rx=\"39.58\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"248.88\" y=\"-300.95\" font-family=\"Times,serif\" font-size=\"14.00\">base_df</text>\n", |
| "</g>\n", |
| "<!-- base_df->spend -->\n", |
| "<g id=\"edge1\" class=\"edge\">\n", |
| "<title>base_df->spend</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M239.92,-288.05C235.75,-280.18 230.7,-270.62 226.04,-261.79\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"228.77,-260.48 221.01,-253.28 222.59,-263.75 228.77,-260.48\"/>\n", |
| "</g>\n", |
| "<!-- base_df->signups -->\n", |
| "<g id=\"edge5\" class=\"edge\">\n", |
| "<title>base_df->signups</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M267.97,-289.81C279.22,-280.86 293.72,-269.33 306.51,-259.16\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"308.38,-261.34 314.03,-252.38 304.02,-255.86 308.38,-261.34\"/>\n", |
| "</g>\n", |
| "<!-- base_df_location -->\n", |
| "<g id=\"node8\" class=\"node\">\n", |
| "<title>base_df_location</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"248.88\" cy=\"-378\" rx=\"98.44\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"248.88\" y=\"-372.95\" font-family=\"Times,serif\" font-size=\"14.00\">Input: base_df_location</text>\n", |
| "</g>\n", |
| "<!-- base_df_location->base_df -->\n", |
| "<g id=\"edge9\" class=\"edge\">\n", |
| "<title>base_df_location->base_df</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M248.88,-359.7C248.88,-352.24 248.88,-343.32 248.88,-334.97\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"252.38,-335.1 248.88,-325.1 245.38,-335.1 252.38,-335.1\"/>\n", |
| "</g>\n", |
| "<!-- spend_mean->spend_zero_mean -->\n", |
| "<g id=\"edge8\" class=\"edge\">\n", |
| "<title>spend_mean->spend_zero_mean</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M254.88,-143.7C254.88,-136.24 254.88,-127.32 254.88,-118.97\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"258.38,-119.1 254.88,-109.1 251.38,-119.1 258.38,-119.1\"/>\n", |
| "</g>\n", |
| "</g>\n", |
| "</svg>\n" |
| ], |
| "text/plain": [ |
| "<graphviz.graphs.Digraph at 0x103dc35b0>" |
| ] |
| }, |
| "execution_count": 7, |
| "metadata": {}, |
| "output_type": "execute_result" |
| } |
| ], |
| "source": [ |
| "# Execute the driver.\n", |
| "\n", |
| "df = dr.execute(output_columns)\n", |
| "print(df)\n", |
| "\n", |
| "# To visualize do `pip install \"sf-hamilton[visualization]\"` if you want these to work\n", |
| "dr.visualize_execution(output_columns)" |
| ] |
| }, |
| { |
| "cell_type": "code", |
| "execution_count": 8, |
| "metadata": {}, |
| "outputs": [ |
| { |
| "data": { |
| "image/svg+xml": [ |
| "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n", |
| "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n", |
| " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n", |
| "<!-- Generated by graphviz version 8.0.5 (20230430.1635)\n", |
| " -->\n", |
| "<!-- Pages: 1 -->\n", |
| "<svg width=\"532pt\" height=\"404pt\"\n", |
| " viewBox=\"0.00 0.00 531.77 404.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", |
| "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 400)\">\n", |
| "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-400 527.77,-400 527.77,4 -4,4\"/>\n", |
| "<!-- spend -->\n", |
| "<g id=\"node1\" class=\"node\">\n", |
| "<title>spend</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"249.8\" cy=\"-234\" rx=\"32.41\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"249.8\" y=\"-228.95\" font-family=\"Times,serif\" font-size=\"14.00\">spend</text>\n", |
| "</g>\n", |
| "<!-- avg_3wk_spend -->\n", |
| "<g id=\"node3\" class=\"node\">\n", |
| "<title>avg_3wk_spend</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"70.8\" cy=\"-162\" rx=\"70.8\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"70.8\" y=\"-156.95\" font-family=\"Times,serif\" font-size=\"14.00\">avg_3wk_spend</text>\n", |
| "</g>\n", |
| "<!-- spend->avg_3wk_spend -->\n", |
| "<g id=\"edge4\" class=\"edge\">\n", |
| "<title>spend->avg_3wk_spend</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M223.77,-222.82C196.27,-212.07 152.29,-194.87 118.53,-181.66\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"120,-178.09 109.41,-177.71 117.45,-184.61 120,-178.09\"/>\n", |
| "</g>\n", |
| "<!-- spend_std_dev -->\n", |
| "<g id=\"node5\" class=\"node\">\n", |
| "<title>spend_std_dev</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"130.8\" cy=\"-90\" rx=\"65.68\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"130.8\" y=\"-84.95\" font-family=\"Times,serif\" font-size=\"14.00\">spend_std_dev</text>\n", |
| "</g>\n", |
| "<!-- spend->spend_std_dev -->\n", |
| "<g id=\"edge6\" class=\"edge\">\n", |
| "<title>spend->spend_std_dev</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M236.61,-217.26C216.01,-192.68 176.03,-144.98 151.55,-115.76\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"153.89,-114.1 144.78,-108.69 148.52,-118.6 153.89,-114.1\"/>\n", |
| "</g>\n", |
| "<!-- spend_zero_mean -->\n", |
| "<g id=\"node6\" class=\"node\">\n", |
| "<title>spend_zero_mean</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"292.8\" cy=\"-90\" rx=\"77.97\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"292.8\" y=\"-84.95\" font-family=\"Times,serif\" font-size=\"14.00\">spend_zero_mean</text>\n", |
| "</g>\n", |
| "<!-- spend->spend_zero_mean -->\n", |
| "<g id=\"edge7\" class=\"edge\">\n", |
| "<title>spend->spend_zero_mean</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M239.02,-216.59C228.42,-198.22 215.35,-167.89 226.8,-144 232.66,-131.78 242.85,-121.49 253.51,-113.33\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"255.34,-115.61 261.48,-106.97 251.29,-109.9 255.34,-115.61\"/>\n", |
| "</g>\n", |
| "<!-- spend_mean -->\n", |
| "<g id=\"node8\" class=\"node\">\n", |
| "<title>spend_mean</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"292.8\" cy=\"-162\" rx=\"57.49\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"292.8\" y=\"-156.95\" font-family=\"Times,serif\" font-size=\"14.00\">spend_mean</text>\n", |
| "</g>\n", |
| "<!-- spend->spend_mean -->\n", |
| "<g id=\"edge10\" class=\"edge\">\n", |
| "<title>spend->spend_mean</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M259.99,-216.41C265,-208.25 271.16,-198.22 276.79,-189.07\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"280.13,-191.31 282.38,-180.96 274.17,-187.65 280.13,-191.31\"/>\n", |
| "</g>\n", |
| "<!-- spend_per_signup -->\n", |
| "<g id=\"node10\" class=\"node\">\n", |
| "<title>spend_per_signup</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"445.8\" cy=\"-162\" rx=\"77.97\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"445.8\" y=\"-156.95\" font-family=\"Times,serif\" font-size=\"14.00\">spend_per_signup</text>\n", |
| "</g>\n", |
| "<!-- spend->spend_per_signup -->\n", |
| "<g id=\"edge11\" class=\"edge\">\n", |
| "<title>spend->spend_per_signup</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M276.64,-223.41C306.83,-212.63 356.56,-194.87 394.31,-181.39\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"395.37,-184.37 403.61,-177.71 393.02,-177.78 395.37,-184.37\"/>\n", |
| "</g>\n", |
| "<!-- spend_zero_mean_unit_variance -->\n", |
| "<g id=\"node2\" class=\"node\">\n", |
| "<title>spend_zero_mean_unit_variance</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"211.8\" cy=\"-18\" rx=\"132.73\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"211.8\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">spend_zero_mean_unit_variance</text>\n", |
| "</g>\n", |
| "<!-- signups -->\n", |
| "<g id=\"node4\" class=\"node\">\n", |
| "<title>signups</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"391.8\" cy=\"-234\" rx=\"39.07\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"391.8\" y=\"-228.95\" font-family=\"Times,serif\" font-size=\"14.00\">signups</text>\n", |
| "</g>\n", |
| "<!-- signups->spend_per_signup -->\n", |
| "<g id=\"edge12\" class=\"edge\">\n", |
| "<title>signups->spend_per_signup</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M404.32,-216.76C410.75,-208.44 418.72,-198.1 425.95,-188.73\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"429.25,-191.18 432.59,-181.12 423.71,-186.9 429.25,-191.18\"/>\n", |
| "</g>\n", |
| "<!-- spend_std_dev->spend_zero_mean_unit_variance -->\n", |
| "<g id=\"edge3\" class=\"edge\">\n", |
| "<title>spend_std_dev->spend_zero_mean_unit_variance</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M150,-72.41C160.06,-63.71 172.58,-52.89 183.72,-43.27\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"185.62,-45.39 190.9,-36.2 181.04,-40.09 185.62,-45.39\"/>\n", |
| "</g>\n", |
| "<!-- spend_zero_mean->spend_zero_mean_unit_variance -->\n", |
| "<g id=\"edge2\" class=\"edge\">\n", |
| "<title>spend_zero_mean->spend_zero_mean_unit_variance</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M273.6,-72.41C263.54,-63.71 251.02,-52.89 239.88,-43.27\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"242.56,-40.09 232.7,-36.2 237.98,-45.39 242.56,-40.09\"/>\n", |
| "</g>\n", |
| "<!-- base_df -->\n", |
| "<g id=\"node7\" class=\"node\">\n", |
| "<title>base_df</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" cx=\"293.8\" cy=\"-306\" rx=\"39.58\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"293.8\" y=\"-300.95\" font-family=\"Times,serif\" font-size=\"14.00\">base_df</text>\n", |
| "</g>\n", |
| "<!-- base_df->spend -->\n", |
| "<g id=\"edge1\" class=\"edge\">\n", |
| "<title>base_df->spend</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M283.37,-288.41C278.17,-280.13 271.75,-269.92 265.93,-260.66\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"268.44,-259.07 260.15,-252.47 262.51,-262.8 268.44,-259.07\"/>\n", |
| "</g>\n", |
| "<!-- base_df->signups -->\n", |
| "<g id=\"edge5\" class=\"edge\">\n", |
| "<title>base_df->signups</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M314.11,-290.5C328.07,-280.52 346.84,-267.11 362.43,-255.98\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"364.08,-258.39 370.18,-249.73 360.01,-252.69 364.08,-258.39\"/>\n", |
| "</g>\n", |
| "<!-- spend_mean->spend_zero_mean -->\n", |
| "<g id=\"edge8\" class=\"edge\">\n", |
| "<title>spend_mean->spend_zero_mean</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M292.8,-143.7C292.8,-136.24 292.8,-127.32 292.8,-118.97\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"296.3,-119.1 292.8,-109.1 289.3,-119.1 296.3,-119.1\"/>\n", |
| "</g>\n", |
| "<!-- base_df_location -->\n", |
| "<g id=\"node9\" class=\"node\">\n", |
| "<title>base_df_location</title>\n", |
| "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"293.8\" cy=\"-378\" rx=\"98.44\" ry=\"18\"/>\n", |
| "<text text-anchor=\"middle\" x=\"293.8\" y=\"-372.95\" font-family=\"Times,serif\" font-size=\"14.00\">Input: base_df_location</text>\n", |
| "</g>\n", |
| "<!-- base_df_location->base_df -->\n", |
| "<g id=\"edge9\" class=\"edge\">\n", |
| "<title>base_df_location->base_df</title>\n", |
| "<path fill=\"none\" stroke=\"black\" d=\"M293.8,-359.7C293.8,-352.24 293.8,-343.32 293.8,-334.97\"/>\n", |
| "<polygon fill=\"black\" stroke=\"black\" points=\"297.3,-335.1 293.8,-325.1 290.3,-335.1 297.3,-335.1\"/>\n", |
| "</g>\n", |
| "</g>\n", |
| "</svg>\n" |
| ], |
| "text/plain": [ |
| "<graphviz.graphs.Digraph at 0x13a85a280>" |
| ] |
| }, |
| "execution_count": 8, |
| "metadata": {}, |
| "output_type": "execute_result" |
| } |
| ], |
| "source": [ |
| "dr.display_all_functions()" |
| ] |
| }, |
| { |
| "cell_type": "code", |
| "execution_count": null, |
| "metadata": {}, |
| "outputs": [], |
| "source": [] |
| } |
| ], |
| "metadata": { |
| "kernelspec": { |
| "display_name": "Python 3 (ipykernel)", |
| "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.9.13" |
| } |
| }, |
| "nbformat": 4, |
| "nbformat_minor": 4 |
| } |