snapper-ml


Namesnapper-ml JSON
Version 0.2.3 PyPI version JSON
download
home_pageNone
SummaryA framework for reproducible machine learning
upload_time2024-11-08 21:49:49
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseMIT License
keywords machine learning reproducibility automation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SnapperML

[![Documentation Status](https://readthedocs.org/projects/snapperml/badge/?version=latest)](https://snapperml.readthedocs.io/en/latest/?badge=latest)

<div style="text-align: center;">
  <img src="docs/assets/new_banner.png" alt="SnapperML">
</div>

SnapperML is a framework for experiment tracking and machine learning operationalization that combines existent and well-supported technologies. These technologies include Docker, [Mlflow](https://mlflow.org/), [Ray](https://github.com/ray-project/ray/), among others.

The framework provides an opinionated workflow to design and execute experiments either on a local environment or the cloud. ml-experiment includes:

- An automatic tracking system
- First-class support for distributed training and hyperparameter optimization
- Command Line Interface (CLI) for packaging and running projects inside containers.

## SnapperML UI

To run snapper UI execute:

```
make UI
```

Open [localhost:4000](http://localhost:4000/) and upload your firsts experiments!

![](docs/assets/UI.png)

To stop snapper UI just execute:

```
make stop_UI
```

## How to install?

The project has some core dependencies:

- mlflow
- optuna>=1.1.0
- ray>=0.8.2
- docker>=4.1.0

The python package can be install using **pip**:

```
pip install snapper-ml
```

Or from this repo:

```
pip install -e .
```

## Deploy

To run snapper first you need to deploy mlflow and optuna. Execute:

```
make docker
```

Once the deploy finished you can execute `snapper-ml` in the CLI. For an ilustrative example, check the [example section](#Example).

## Architecture

The framework main core is divided into four modules that interact with the user through a Command-Line Interface (CLI) and a Python library.
The objective of the library is to minimize the code changes required to instrument scripts to be executed by the Job Runner and to provide the abstractions to interact with the Tracking and Hyperparameter Optimization engines. On the other hand, the CLI is in charge of executing scripts either in a local
environment or a remote environment.

![Architecture Overview](./thesis/source/figures/ml_experiment_overview.svg)

## Documentation

The documentation is available [here](https://snapperml.readthedocs.io/en/latest/)

## Example

```python
# train_svm.py

from snapper_ml import job

@job
def main(C, kernel, gamma='scale'):
    np.random.seed(1234)
    X_train, X_val, y_train, y_val = load_data()
    model = SVC(C=C, gamma=gamma, kernel=kernel)
    model.fit(X_train, y_train)
    accuracy = model.score(X_val, y_val)
    return {'val_accuracy': accuracy}


if __name__ == '__main__':
    main()
```

```yaml
# train_svm.yaml

name: "SVM"
kind: "group"
num_trials: 12
sampler: TPE

param_space:
  C: loguniform(0.01, 1000)
  gamma: choice(['scale', 'auto'])

metric:
  name: val_accuracy
  direction: maximize

ray_config:
  num_cpus: 4

run:
  - train_svm.py
```

```bash

snapper-ml --config_file=train_svm.yaml
```

There are more examples in the [examples folder](https://github.com/yerasiito/SnapperML/tree/master/examples).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "snapper-ml",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "machine learning, reproducibility, automation",
    "author": null,
    "author_email": "Antonio Molner Domenech <antonio.molner@correo.ugr.es>, Yeray L\u00f3pez Ram\u00edrez <ylopezramirez@correo.ugr.es>",
    "download_url": "https://files.pythonhosted.org/packages/c2/c0/6a6d1938f11973ace77459779e8d12225efa4b6cfdb3ec37ade4b27a2c19/snapper_ml-0.2.3.tar.gz",
    "platform": null,
    "description": "# SnapperML\n\n[![Documentation Status](https://readthedocs.org/projects/snapperml/badge/?version=latest)](https://snapperml.readthedocs.io/en/latest/?badge=latest)\n\n<div style=\"text-align: center;\">\n  <img src=\"docs/assets/new_banner.png\" alt=\"SnapperML\">\n</div>\n\nSnapperML is a framework for experiment tracking and machine learning operationalization that combines existent and well-supported technologies. These technologies include Docker, [Mlflow](https://mlflow.org/), [Ray](https://github.com/ray-project/ray/), among others.\n\nThe framework provides an opinionated workflow to design and execute experiments either on a local environment or the cloud. ml-experiment includes:\n\n- An automatic tracking system\n- First-class support for distributed training and hyperparameter optimization\n- Command Line Interface (CLI) for packaging and running projects inside containers.\n\n## SnapperML UI\n\nTo run snapper UI execute:\n\n```\nmake UI\n```\n\nOpen [localhost:4000](http://localhost:4000/) and upload your firsts experiments!\n\n![](docs/assets/UI.png)\n\nTo stop snapper UI just execute:\n\n```\nmake stop_UI\n```\n\n## How to install?\n\nThe project has some core dependencies:\n\n- mlflow\n- optuna>=1.1.0\n- ray>=0.8.2\n- docker>=4.1.0\n\nThe python package can be install using **pip**:\n\n```\npip install snapper-ml\n```\n\nOr from this repo:\n\n```\npip install -e .\n```\n\n## Deploy\n\nTo run snapper first you need to deploy mlflow and optuna. Execute:\n\n```\nmake docker\n```\n\nOnce the deploy finished you can execute `snapper-ml` in the CLI. For an ilustrative example, check the [example section](#Example).\n\n## Architecture\n\nThe framework main core is divided into four modules that interact with the user through a Command-Line Interface (CLI) and a Python library.\nThe objective of the library is to minimize the code changes required to instrument scripts to be executed by the Job Runner and to provide the abstractions to interact with the Tracking and Hyperparameter Optimization engines. On the other hand, the CLI is in charge of executing scripts either in a local\nenvironment or a remote environment.\n\n![Architecture Overview](./thesis/source/figures/ml_experiment_overview.svg)\n\n## Documentation\n\nThe documentation is available [here](https://snapperml.readthedocs.io/en/latest/)\n\n## Example\n\n```python\n# train_svm.py\n\nfrom snapper_ml import job\n\n@job\ndef main(C, kernel, gamma='scale'):\n    np.random.seed(1234)\n    X_train, X_val, y_train, y_val = load_data()\n    model = SVC(C=C, gamma=gamma, kernel=kernel)\n    model.fit(X_train, y_train)\n    accuracy = model.score(X_val, y_val)\n    return {'val_accuracy': accuracy}\n\n\nif __name__ == '__main__':\n    main()\n```\n\n```yaml\n# train_svm.yaml\n\nname: \"SVM\"\nkind: \"group\"\nnum_trials: 12\nsampler: TPE\n\nparam_space:\n  C: loguniform(0.01, 1000)\n  gamma: choice(['scale', 'auto'])\n\nmetric:\n  name: val_accuracy\n  direction: maximize\n\nray_config:\n  num_cpus: 4\n\nrun:\n  - train_svm.py\n```\n\n```bash\n\nsnapper-ml --config_file=train_svm.yaml\n```\n\nThere are more examples in the [examples folder](https://github.com/yerasiito/SnapperML/tree/master/examples).\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "A framework for reproducible machine learning",
    "version": "0.2.3",
    "project_urls": {
        "homepage": "https://github.com/SnapperML/SnapperML"
    },
    "split_keywords": [
        "machine learning",
        " reproducibility",
        " automation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4cdb1aea8bf0e5245bd0f8df4007f020a724b4e12b5240fd9f4b46e0c0fcd77f",
                "md5": "84f122e61e50a0c24825bda0fded1b88",
                "sha256": "3a06b633bdb6787b01b89176d0cda4290d6473dccc723a8939e8d66523c89312"
            },
            "downloads": -1,
            "filename": "snapper_ml-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "84f122e61e50a0c24825bda0fded1b88",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 1338229,
            "upload_time": "2024-11-08T21:49:47",
            "upload_time_iso_8601": "2024-11-08T21:49:47.511346Z",
            "url": "https://files.pythonhosted.org/packages/4c/db/1aea8bf0e5245bd0f8df4007f020a724b4e12b5240fd9f4b46e0c0fcd77f/snapper_ml-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c2c06a6d1938f11973ace77459779e8d12225efa4b6cfdb3ec37ade4b27a2c19",
                "md5": "f1bb761651a1ddaa55bedbfeb56d550a",
                "sha256": "3447c6e627696c119511e639f85397e9a39f14fa951595128134a4154c4f1ae2"
            },
            "downloads": -1,
            "filename": "snapper_ml-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "f1bb761651a1ddaa55bedbfeb56d550a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 1336346,
            "upload_time": "2024-11-08T21:49:49",
            "upload_time_iso_8601": "2024-11-08T21:49:49.760545Z",
            "url": "https://files.pythonhosted.org/packages/c2/c0/6a6d1938f11973ace77459779e8d12225efa4b6cfdb3ec37ade4b27a2c19/snapper_ml-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-08 21:49:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SnapperML",
    "github_project": "SnapperML",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "snapper-ml"
}
        
Elapsed time: 0.53140s