Docker with the <code>run-docker.sh</code> script</li>\n<li>Manually, using the <code>conda</code> CLI</li>\n</ul>\n<h3>Running the notebook with <code>run.sh</code></h3>\n<p>You can use the <code>run.sh</code> script to build your environment and run this notebook with a single command.</p>\n<h4>Prerequisite: conda (version 4.4+)</h4>\n<p>You can install the <code>conda</code> CLI by installing <a href=https://www.optimizely.com/"https://www.anaconda.com/distribution//">Anaconda or <a href=https://www.optimizely.com/"https://docs.conda.io/en/latest/miniconda.html/">Miniconda.

/n

Running Jupyter Lab</h4>\n<p>This lab directory contains a handy script for building your conda environment and running Jupyter Lab. To run it, simply use</p>\n<pre><code class=\"language-sh\">bash bin/run.sh\n</code></pre>\n<p>That's it, you're done!</p>\n<h3>Running this notebook with Docker</h3>\n<p>If you have <a href=https://www.optimizely.com/"https://www.docker.com//">Docker installed, you can run PySpark and Jupyter Lab without installing any other dependencies.</p>\n<p>Execute <code>run-docker.sh</code> in the <code>./bin</code> directory to open Jupyter Lab in a Docker container:</p>\n<pre><code class=\"language-sh\">bash bin/run-docker.sh\n</code></pre>\n<p><strong>Note:</strong> Docker makes it easy to get started with PySpark, but it adds overhead and may require <a href=https://www.optimizely.com/"https://docs.docker.com/config/containers/resource_constraints//">additional configuration</a> to handle large workloads.</p>\n<h3>Running this notebook manually</h3>\n<p>If you prefer to build and activate your conda environment manually, you can use the <code>conda</code> CLI and the environment specification files in the <code>./lab_env</code> directory to do so.</p>\n<h4>Prerequisite: conda (version 4.4+)</h4>\n<p>You can install the <code>conda</code> CLI by installing <a href=https://www.optimizely.com/"https://www.anaconda.com/distribution//">Anaconda or <a href=https://www.optimizely.com/"https://docs.conda.io/en/latest/miniconda.html/">Miniconda.

/n

Building and activating your Aanconda environment</h4>\n<p>Start by building (or updating) and activating your anaconda environment. This step will install <a href=https://www.optimizely.com/"https://openjdk.java.net//">OpenJDK, PySpark, <a href=https://www.optimizely.com/"https://jupyter.org//">Jupyter Lab</a>, and other necessary dependencies.</p>\n<pre><code class=\"language-sh\">conda env update --file lab_env/base.yml --name optimizelylabs\nconda env update --file lab_env/labs.yml --name optimizelylabs\nconda activate optimizelylabs\n</code></pre>\n<p>Next, install a jupyter kernel for this environment:</p>\n<pre><code class=\"language-sh\">python -m ipykernel install --user \\\n --name optimizelylabs \\\n --display-name=\"Python 3 (Optimizely Labs Environment)\"\n</code></pre>\n<p>Finally, start Jupyter Lab in your working directory:</p>\n<pre><code class=\"language-sh\">jupyter lab .\n</code></pre>\n<h2>Specifying a custom data directory</h2>\n<p>The notebook in this lab will load Enriched Event data from <code>example_data/</code> in the lab directory. If you wish to load data from another directory, you can use the <code>OPTIMIZELY_DATA_DIR</code> environment variable. For example:</p>\n<pre><code class=\"language-sh\">export OPTIMIZELY_DATA_DIR=~/optimizely_data\n</code></pre>\n<p>Once <code>OPTIMIZELY_DATA_DIR</code> has been set, launch Jupyter Lab using one of the approaches described above. The Lab notebook should load data from your custom directory.</p>","labels":"jupyter, data, analysis","revisionDate":"2020-09-15","resourceFile":null,"resourceFileName":null,"author":null,"repositoryUrl":"https://raw.githubusercontent.com/optimizely/labs/master/labs/computing-experiment-metrics/README.md","labelsLabel":"Labels","publishedLabel":"Published","resourcesLabel":"Resources","repositoryLabel":"Repository","authorLabel":"Author"}" data-redux="false" data-router="false">

Computing metrics with event-level experiment data

In this Lab, we'll walk through an end-to-end workflow for computing a series of metrics with data collected by both Optimizely and a third party during an Optimizely Full Stack experiment.

Running this notebook

There are several ways to run this notebook locally:

  • Using the run.sh script
  • Using Docker with the run-docker.sh script
  • Manually, using the conda CLI

Running the notebook with run.sh

You can use the run.sh script to build your environment and run this notebook with a single command.

Prerequisite: conda (version 4.4+)

You can install the conda CLI by installing Anaconda or Miniconda.

Running Jupyter Lab

This lab directory contains a handy script for building your conda environment and running Jupyter Lab. To run it, simply use

bash bin/run.sh

That's it, you're done!

Running this notebook with Docker

If you have Docker installed, you can run PySpark and Jupyter Lab without installing any other dependencies.

Execute run-docker.sh in the ./bin directory to open Jupyter Lab in a Docker container:

bash bin/run-docker.sh

Note: Docker makes it easy to get started with PySpark, but it adds overhead and may require additional configuration to handle large workloads.

Running this notebook manually

If you prefer to build and activate your conda environment manually, you can use the conda CLI and the environment specification files in the ./lab_env directory to do so.

Prerequisite: conda (version 4.4+)

You can install the conda CLI by installing Anaconda or Miniconda.

Building and activating your Aanconda environment

Start by building (or updating) and activating your anaconda environment. This step will install OpenJDK, PySpark, Jupyter Lab, and other necessary dependencies.

conda env update --file lab_env/base.yml --name optimizelylabs
conda env update --file lab_env/labs.yml --name optimizelylabs
conda activate optimizelylabs

Next, install a jupyter kernel for this environment:

python -m ipykernel install --user \
    --name optimizelylabs \
    --display-name="Python 3 (Optimizely Labs Environment)"

Finally, start Jupyter Lab in your working directory:

jupyter lab .

Specifying a custom data directory

The notebook in this lab will load Enriched Event data from example_data/ in the lab directory. If you wish to load data from another directory, you can use the OPTIMIZELY_DATA_DIR environment variable. For example:

export OPTIMIZELY_DATA_DIR=~/optimizely_data

Once OPTIMIZELY_DATA_DIR has been set, launch Jupyter Lab using one of the approaches described above. The Lab notebook should load data from your custom directory.

Additional links