Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Experiments demo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# coding: utf-8
# # Accessing pref-flipping experiments data
#
# This notebook briefly demonstrates how to access the raw data for participants in experiments.
#
# You may be able to get the information you need from the [Experiments Viewer](https://moz-experiments-viewer.herokuapp.com/) dashboard.
#
# If not, then continue reading for a quick introduction.
# In[1]:
from moztelemetry.dataset import Dataset
# In[3]:
cohorts = Dataset.from_source("telemetry-cohorts")
cohorts.schema
# Fetch some example data for a single day and a single experiment.
# In[9]:
experiment = "shield-public-infobar-display-bug1368141"
pings = cohorts.where(submissionDate="20170701") .where(experimentId=experiment) .records(sc)
# Cache the dataset since it's small and we'll be poking around in it several times.
# In[10]:
pings.cache()
# How many pings did we observe in total?
# In[11]:
pings.count()
# What were the different ping types observed for this experiment on this day?
# In[13]:
pings.map(lambda f: f["meta"].get("docType", "None")).countByValue()
# How many different `clientId`s submitted data for this experiment on this day?
# In[14]:
pings.map(lambda f: f["meta"].get("clientId", "None")).distinct().count()
# ### Where to go from here?
#
# You will most likely want to fetch data for *all* days of an experiment, which you can do by leaving out the `submissionDate` parameter.
#
# You will probably also want to fetch particular document types, so you can add a new `docType` filter.
#
# You may also want to look at the `experiments_aggregates` data set which contains pre-aggregated results for each experiment and branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment