memento-ml


Namememento-ml JSON
Version 1.1.0 PyPI version JSON
download
home_page
SummaryA Python library for running computationally expensive experiments
upload_time2023-05-05 01:42:57
maintainer
docs_urlNone
author
requires_python>=3.8
licenseBSD 3-Clause License Copyright (c) 2023, wickerlab Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords experiment parallel sklearn machine learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI](https://img.shields.io/pypi/v/memento-ml)](https://pypi.org/project/memento-ml/)
![Python versions](https://img.shields.io/pypi/pyversions/memento-ml)

# MEMENTO

`MEMENTO` is a Python library for running computationally expensive experiments.

Running complex sets of machine learning experiments is challenging and time-consuming due to the lack of a unified framework.
This leaves researchers forced to spend time implementing necessary features such as parallelization, caching, and checkpointing themselves instead of focussing on their project.
To simplify the process, we introduce `MEMENTO`, a Python package that is designed to aid researchers and data scientists in the efficient management and execution of computationally intensive experiments.
`MEMENTO` has the capacity to streamline any experimental pipeline by providing a straightforward configuration matrix and the ability to concurrently run experiments across multiple threads.

If you need to run a large number of time-consuming experiments `MEMENTO` can help:

- Structure your configuration
- Parallelize experiments across CPUs
- Save and restore results
- Checkpoint in-progress experiments
- Send notifications when experiments fail or finish

[![Demo video](https://img.youtube.com/vi/GEtdCl1ZUWc/0.jpg)](http://www.youtube.com/watch?v=GEtdCl1ZUWc)

## Getting Started

`MEMENTO` is officially available on PyPl. To install the package:

### Install

```bash
pip install memento-ml
```

### The Configuration Matrix

The core of `MEMENTO` is a configuration `matrix` that describes the list of experiments you
want `MEMENTO` to run. This must contain a key `parameters` which is itself a dict, this describes
each paramter you want to vary for your experiments and their values.

As an example let's say you wanted to test a few simple linear classifiers on a number of
image recognition datasets. You might write something like this:

> Don't worry if you're not working on machine learning, this is just an example.

```python
matrix = {
  "parameters": {
    "model": [
      sklearn.svm.SVC,
      sklearn.linear_model.Perceptron,
      sklearn.linear_model.LogisticRegression
    ],
    "dataset": ["imagenet", "mnist", "cifar10", "quickdraw"]
  }
}
```

`MEMENTO` would then generate 12 configurations by taking the _cartesian product_ of the
parameters.

Frequently you might also want to set some global configuration values, such as a regularization
parameter or potentially even change your preprocessing pipeline. In this case `MEMENTO` also
accepts a "settings" key. These settings apply to all experiments and can be accessed from the
configuration list as well as individual configurations.

```python
matrix = {
  "parameters": ...,
  "settings": {
    "regularization": 1e-1,
    "preprocessing": make_preprocessing_pipeline()
  }
}
```

You can also exclude specific parameter configurations. Returning to our machine learning
example, if you know SVCs perform poorly on cifar10 you might decide to skip that
experiment entirely. This is done with the "exclude" key:

```python
matrix = {
  "parameters": ...,
  "exclude": [
    {"model": sklearn.svm.SVC, "dataset": "cifar10"}
  ]
}
```

### Running an experiment

Along with a configuration matrix you need some code to run your experiments. This can be any
`Callable` such as a function, lambda, class, or class method.

```python
from memento import Memento, Config, Context

def experiment(context: Context, config: Config):
  classifier = config.model()
  dataset = fetch_dataset(config.dataset)

  classifier.fit(*dataset)

  return classifier

Memento(experiment).run(matrix)
```

You can also perform a dry run to check you've gotten the matrix correct.

```python
Memento(experiment).run(matrix, dry_run=True)
```

```python
Running configurations:
  {'model': sklearn.svm.SVC, 'dataset': 'imagenet'}
  {'model': sklearn.svm.SVC, 'dataset': 'mnist'}
  {'model': sklearn.svm.SVC, 'dataset': 'cifar10'}
  {'model': sklearn.svm.SVC, 'dataset': 'quickdraw'}
  {'model': sklearn.linear_model.Perceptron, 'dataset': 'imagenet'}
  ...
Exiting due to dry run
```

## Code demo

- Code demo can be found [here](demo).
- `MEMENTO` does not depend on any ML packages, e.g., `scikit-learn`. The `scikit-learn` and `jupyterlab` packages are required to run the demo (`./demo/*`).

```bash
pip install memento-ml scikit-learn jupyterlab
```

## Roadmap

- Finish HPC support
- Improve result serialisation
- Improve customization for notification

## Contributors

- [Zac Pullar-Strecker](https://github.com/zacps)
- [Feras Albaroudi](https://github.com/NeedsSoySauce)
- [Liam Scott-Russell](https://github.com/Liam-Scott-Russell)
- [Joshua de Wet](https://github.com/Dewera)
- [Nipun Jasti](https://github.com/watefeenex)
- [James Lamberton](https://github.com/JamesLamberton)
- [Xinglong (Luke) Chang](https://github.com/changx03)
- [Liam Brydon](https://github.com/MyCreativityOutlet)
- [Ioannis Ziogas](izio995@aucklanduni.ac.nz)
- [Katharina Dost](katharina.dost@auckland.ac.nz)
- [Joerg Wicker](https://github.com/joergwicker)

## License

MEMENTO is licensed under the [3-Clause BSD License](https://opensource.org/licenses/BSD-3-Clause) license.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "memento-ml",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "experiment,parallel,sklearn,machine learning",
    "author": "",
    "author_email": "Wickerlab dev team <luke.x.chang@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/7a/c5/c48ec79413de700e037681893ddb6b8d4aacdefe9266f69b715bb80b0215/memento-ml-1.1.0.tar.gz",
    "platform": null,
    "description": "[![PyPI](https://img.shields.io/pypi/v/memento-ml)](https://pypi.org/project/memento-ml/)\r\n![Python versions](https://img.shields.io/pypi/pyversions/memento-ml)\r\n\r\n# MEMENTO\r\n\r\n`MEMENTO` is a Python library for running computationally expensive experiments.\r\n\r\nRunning complex sets of machine learning experiments is challenging and time-consuming due to the lack of a unified framework.\r\nThis leaves researchers forced to spend time implementing necessary features such as parallelization, caching, and checkpointing themselves instead of focussing on their project.\r\nTo simplify the process, we introduce `MEMENTO`, a Python package that is designed to aid researchers and data scientists in the efficient management and execution of computationally intensive experiments.\r\n`MEMENTO` has the capacity to streamline any experimental pipeline by providing a straightforward configuration matrix and the ability to concurrently run experiments across multiple threads.\r\n\r\nIf you need to run a large number of time-consuming experiments `MEMENTO` can help:\r\n\r\n- Structure your configuration\r\n- Parallelize experiments across CPUs\r\n- Save and restore results\r\n- Checkpoint in-progress experiments\r\n- Send notifications when experiments fail or finish\r\n\r\n[![Demo video](https://img.youtube.com/vi/GEtdCl1ZUWc/0.jpg)](http://www.youtube.com/watch?v=GEtdCl1ZUWc)\r\n\r\n## Getting Started\r\n\r\n`MEMENTO` is officially available on PyPl. To install the package:\r\n\r\n### Install\r\n\r\n```bash\r\npip install memento-ml\r\n```\r\n\r\n### The Configuration Matrix\r\n\r\nThe core of `MEMENTO` is a configuration `matrix` that describes the list of experiments you\r\nwant `MEMENTO` to run. This must contain a key `parameters` which is itself a dict, this describes\r\neach paramter you want to vary for your experiments and their values.\r\n\r\nAs an example let's say you wanted to test a few simple linear classifiers on a number of\r\nimage recognition datasets. You might write something like this:\r\n\r\n> Don't worry if you're not working on machine learning, this is just an example.\r\n\r\n```python\r\nmatrix = {\r\n  \"parameters\": {\r\n    \"model\": [\r\n      sklearn.svm.SVC,\r\n      sklearn.linear_model.Perceptron,\r\n      sklearn.linear_model.LogisticRegression\r\n    ],\r\n    \"dataset\": [\"imagenet\", \"mnist\", \"cifar10\", \"quickdraw\"]\r\n  }\r\n}\r\n```\r\n\r\n`MEMENTO` would then generate 12 configurations by taking the _cartesian product_ of the\r\nparameters.\r\n\r\nFrequently you might also want to set some global configuration values, such as a regularization\r\nparameter or potentially even change your preprocessing pipeline. In this case `MEMENTO` also\r\naccepts a \"settings\" key. These settings apply to all experiments and can be accessed from the\r\nconfiguration list as well as individual configurations.\r\n\r\n```python\r\nmatrix = {\r\n  \"parameters\": ...,\r\n  \"settings\": {\r\n    \"regularization\": 1e-1,\r\n    \"preprocessing\": make_preprocessing_pipeline()\r\n  }\r\n}\r\n```\r\n\r\nYou can also exclude specific parameter configurations. Returning to our machine learning\r\nexample, if you know SVCs perform poorly on cifar10 you might decide to skip that\r\nexperiment entirely. This is done with the \"exclude\" key:\r\n\r\n```python\r\nmatrix = {\r\n  \"parameters\": ...,\r\n  \"exclude\": [\r\n    {\"model\": sklearn.svm.SVC, \"dataset\": \"cifar10\"}\r\n  ]\r\n}\r\n```\r\n\r\n### Running an experiment\r\n\r\nAlong with a configuration matrix you need some code to run your experiments. This can be any\r\n`Callable` such as a function, lambda, class, or class method.\r\n\r\n```python\r\nfrom memento import Memento, Config, Context\r\n\r\ndef experiment(context: Context, config: Config):\r\n  classifier = config.model()\r\n  dataset = fetch_dataset(config.dataset)\r\n\r\n  classifier.fit(*dataset)\r\n\r\n  return classifier\r\n\r\nMemento(experiment).run(matrix)\r\n```\r\n\r\nYou can also perform a dry run to check you've gotten the matrix correct.\r\n\r\n```python\r\nMemento(experiment).run(matrix, dry_run=True)\r\n```\r\n\r\n```python\r\nRunning configurations:\r\n  {'model': sklearn.svm.SVC, 'dataset': 'imagenet'}\r\n  {'model': sklearn.svm.SVC, 'dataset': 'mnist'}\r\n  {'model': sklearn.svm.SVC, 'dataset': 'cifar10'}\r\n  {'model': sklearn.svm.SVC, 'dataset': 'quickdraw'}\r\n  {'model': sklearn.linear_model.Perceptron, 'dataset': 'imagenet'}\r\n  ...\r\nExiting due to dry run\r\n```\r\n\r\n## Code demo\r\n\r\n- Code demo can be found [here](demo).\r\n- `MEMENTO` does not depend on any ML packages, e.g., `scikit-learn`. The `scikit-learn` and `jupyterlab` packages are required to run the demo (`./demo/*`).\r\n\r\n```bash\r\npip install memento-ml scikit-learn jupyterlab\r\n```\r\n\r\n## Roadmap\r\n\r\n- Finish HPC support\r\n- Improve result serialisation\r\n- Improve customization for notification\r\n\r\n## Contributors\r\n\r\n- [Zac Pullar-Strecker](https://github.com/zacps)\r\n- [Feras Albaroudi](https://github.com/NeedsSoySauce)\r\n- [Liam Scott-Russell](https://github.com/Liam-Scott-Russell)\r\n- [Joshua de Wet](https://github.com/Dewera)\r\n- [Nipun Jasti](https://github.com/watefeenex)\r\n- [James Lamberton](https://github.com/JamesLamberton)\r\n- [Xinglong (Luke) Chang](https://github.com/changx03)\r\n- [Liam Brydon](https://github.com/MyCreativityOutlet)\r\n- [Ioannis Ziogas](izio995@aucklanduni.ac.nz)\r\n- [Katharina Dost](katharina.dost@auckland.ac.nz)\r\n- [Joerg Wicker](https://github.com/joergwicker)\r\n\r\n## License\r\n\r\nMEMENTO is licensed under the [3-Clause BSD License](https://opensource.org/licenses/BSD-3-Clause) license.\r\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License  Copyright (c) 2023, wickerlab  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
    "summary": "A Python library for running computationally expensive experiments",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/wickerlab/memento"
    },
    "split_keywords": [
        "experiment",
        "parallel",
        "sklearn",
        "machine learning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "589b93a0149a8ca99be02bb03d002e661820ee29c9c24e7591ff484260fd7d1e",
                "md5": "8c51314e336c99bafdc1a39c8d31a5cb",
                "sha256": "b3dfb4d698a5c256b4ecd2af6aa34dabbf659fc88fa0a88ca44e662c889ae855"
            },
            "downloads": -1,
            "filename": "memento_ml-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8c51314e336c99bafdc1a39c8d31a5cb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 21112,
            "upload_time": "2023-05-05T01:42:55",
            "upload_time_iso_8601": "2023-05-05T01:42:55.370139Z",
            "url": "https://files.pythonhosted.org/packages/58/9b/93a0149a8ca99be02bb03d002e661820ee29c9c24e7591ff484260fd7d1e/memento_ml-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7ac5c48ec79413de700e037681893ddb6b8d4aacdefe9266f69b715bb80b0215",
                "md5": "2a8750cb8127ee4e145570d07cc5e33c",
                "sha256": "08bcd491ca8a81dfc07eb2c9a5daa72bc44cdbf1c93f7d7204ce9cc38fae992e"
            },
            "downloads": -1,
            "filename": "memento-ml-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2a8750cb8127ee4e145570d07cc5e33c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 27356,
            "upload_time": "2023-05-05T01:42:57",
            "upload_time_iso_8601": "2023-05-05T01:42:57.146350Z",
            "url": "https://files.pythonhosted.org/packages/7a/c5/c48ec79413de700e037681893ddb6b8d4aacdefe9266f69b715bb80b0215/memento-ml-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-05 01:42:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wickerlab",
    "github_project": "memento",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "memento-ml"
}
        
Elapsed time: 0.06094s