Package: papersweep
# Papersweep
> Combining papermill and wandb sweeps for frictionless experiments with notebooks.I often find myself coding a machine learning experiment in a Jupyter Notebook, using [wandb](https://www.wandb.com/) to visualize and track the results of the runs. When the experiment is drafted, I always have questions such as: How will the performance be affected by the parametera? What if I change the number of items of the dataset, or change the dataset completely?[wandb sweeps](https://docs.wandb.com/sweeps) are a great tool to solve these questions. However, sweeping requires that you define a specific training function for the sweep, which I find redundant, specially when the code for training is already in the Jupyter Notebook. Furthermore, if I make some changes in the original notebook, I have to be sure that I change the sweep function too.This library just provides a single command,papersweep, which uses the library [papermill](https://github.com/nteract/papermill) to execute a notebook as the function of a wandb sweep. The only thing that has to be changed in the notebook is the way the config parameters are declared inwandb.config.As an example, ifais a parameter in your notebook declared as:`python wandb.config.a = 3 `Just changing that line to:`python wandb.config.a =ifnone(wandb.config.get('a'),3) `will use the default value3in case the notebook is executed as a standalone run (i.e, without a sweep), and in case the notebook is executed as a sweep function, it will use the value injected from the sweep configuration. This provides a frictionless way of using your Jupyter Notebooks both for single runs and sweep functions.## Installpip install papersweep## How to use–helpprovides command help.` $ `input_nbcontains a path to the notebook with the experiment you want to use as function of the sweep.sweep_configis a path to a YAML file with the configuration of the sweep. An example is given inexamples/sweep_config.yaml. More information aboyt sweep configurations in the [official docs](https://docs.wandb.com/sweeps/configuration).pm_paramsis a YAML file with extra configuration for the notebook execution aside from the sweep parameters. Those parameters will be injected in the notebook bypapermill, so they need to be placed in one cell tagged asparameters(See the documentation ofpapermillto see how to tag a cell in a Jupyter Notebook).sweep_idallows to reuse an already existing sweep instead of creating a new one.## Example with time series classificationThe notebook_example_tsai.ipynbtrains a time series classifier using deep learning with the librarytsai`(https://github.com/timeseriesAI/tsai). The dataset (`dsid) and the deep learning architecture (arch) are part of thewandb.configconfiguration parameters.The fileexamples/sweep_config.yamlgives grid-like experiment in which multiple datasets and architectures are tried, looking for the combination that achieves better accuracyRunning the following commandin a terminal:papersweep –input_nb ./_example_tsai.ipynb –sweep_config ./examples/sweep_config.yaml —entity vrodriguezf –project papersweepwill run the notebook./example_tsai.ipynbonce for every iteration of the sweep, and log the results [in a dashboard](https://wandb.ai/vrodriguezf/papersweep/sweeps/qh09r37b?workspace=user-vrodriguezf) that you can interact and play with.