Name | gmmx JSON |
Version |
0.1
JSON |
| download |
home_page | None |
Summary | A minimal implementation of Gaussian Mixture Models in Jax |
upload_time | 2024-12-18 14:56:30 |
maintainer | None |
docs_url | None |
author | None |
requires_python | <4.0,>=3.9 |
license | None |
keywords |
python
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# GMMX: Gaussian Mixture Models in Jax
[![Release](https://img.shields.io/github/v/release/adonath/gmmx)](https://img.shields.io/github/v/release/adonath/gmmx)
[![Build status](https://img.shields.io/github/actions/workflow/status/adonath/gmmx/main.yml?branch=main)](https://github.com/adonath/gmmx/actions/workflows/main.yml?query=branch%3Amain)
[![codecov](https://codecov.io/gh/adonath/gmmx/branch/main/graph/badge.svg)](https://codecov.io/gh/adonath/gmmx)
[![Commit activity](https://img.shields.io/github/commit-activity/m/adonath/gmmx)](https://img.shields.io/github/commit-activity/m/adonath/gmmx)
[![License](https://img.shields.io/github/license/adonath/gmmx)](https://img.shields.io/github/license/adonath/gmmx)
<p align="center">
<img width="50%" src="docs/_static/gmmx-logo.png" alt="GMMX Logo"/>
</p>
A minimal implementation of Gaussian Mixture Models in Jax
- **Github repository**: <https://github.com/adonath/gmmx/>
- **Documentation** <https://adonath.github.io/gmmx/>
## Installation
`gmmx` can be installed via pip:
```bash
pip install gmmx
```
## Usage
```python
from gmmx import GaussianMixtureModelJax, EMFitter
# Create a Gaussian Mixture Model with 16 components and 32 features
gmm = GaussianMixtureModelJax.create(n_components=16, n_features=32)
# Draw samples from the model
n_samples = 10_000
x = gmm.sample(n_samples)
# Fit the model to the data
em_fitter = EMFitter(tol=1e-3, max_iter=100)
gmm_fitted = em_fitter.fit(x=x, gmm=gmm)
```
## Why Gaussian Mixture models?
What are Gaussian Mixture Models (GMM) useful for in the age of deep learning? GMMs might have come out of fashion for classification tasks, but they still
have a few properties that make them useful in certain scenarios:
- They are universal approximators, meaning that given enough components they can approximate any distribution.
- Their likelihood can be evaluated in closed form, which makes them useful for generative modeling.
- They are rather fast to train and evaluate.
One of these applications is in the context of image reconstruction, where GMMs can be used to model the distribution and pixel correlations of local (patch based)
image features. This can be useful for tasks like image denoising or inpainting. One of these methods I have used them for is [Jolideco](https://github.com/jolideco/jolideco).
Speed up the training of O(10^6) patches was the main motivation for `gmmx`.
## Benchmarks
Here are some results from the benchmarks in the `benchmarks` folder comparing against Scikit-Learn. The benchmarks were run on a 2021 MacBook Pro with an M1 Pro chip.
### Prediction
| Time vs. Number of Components | Time vs. Number of Samples | Time vs. Number of Features |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| ![Time vs. Number of Components](docs/_static/time-vs-n-components-predict.png) | ![Time vs. Number of Samples](docs/_static/time-vs-n-samples-predict.png) | ![Time vs. Number of Features](docs/_static/time-vs-n-features-predict.png) |
For prediction the speedup is around 2x for varying number of components and features. For the number of samples the cross-over point is around O(10^4) samples.
### Training Time
| Time vs. Number of Components | Time vs. Number of Samples | Time vs. Number of Features |
| --------------------------------------------------------------------------- | --------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| ![Time vs. Number of Components](docs/_static/time-vs-n-components-fit.png) | ![Time vs. Number of Samples](docs/_static/time-vs-n-samples-fit.png) | ![Time vs. Number of Features](docs/_static/time-vs-n-features-fit.png) |
For training the speedup is around 10x on the same architecture. However there is no guarantee that it will converge to the same solution as Scikit-Learn. But there are some tests in the `tests` folder that compare the results of the two implementations.
Raw data
{
"_id": null,
"home_page": null,
"name": "gmmx",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "python",
"author": null,
"author_email": "Axel Donath <mail@axeldonath.com>",
"download_url": "https://files.pythonhosted.org/packages/15/e5/b1d7be3bf8ef27126d3d2a5612120ce344db4dfa8eedf3014b2432be6b8f/gmmx-0.1.tar.gz",
"platform": null,
"description": "# GMMX: Gaussian Mixture Models in Jax\n\n[![Release](https://img.shields.io/github/v/release/adonath/gmmx)](https://img.shields.io/github/v/release/adonath/gmmx)\n[![Build status](https://img.shields.io/github/actions/workflow/status/adonath/gmmx/main.yml?branch=main)](https://github.com/adonath/gmmx/actions/workflows/main.yml?query=branch%3Amain)\n[![codecov](https://codecov.io/gh/adonath/gmmx/branch/main/graph/badge.svg)](https://codecov.io/gh/adonath/gmmx)\n[![Commit activity](https://img.shields.io/github/commit-activity/m/adonath/gmmx)](https://img.shields.io/github/commit-activity/m/adonath/gmmx)\n[![License](https://img.shields.io/github/license/adonath/gmmx)](https://img.shields.io/github/license/adonath/gmmx)\n\n<p align=\"center\">\n<img width=\"50%\" src=\"docs/_static/gmmx-logo.png\" alt=\"GMMX Logo\"/>\n</p>\n\nA minimal implementation of Gaussian Mixture Models in Jax\n\n- **Github repository**: <https://github.com/adonath/gmmx/>\n- **Documentation** <https://adonath.github.io/gmmx/>\n\n## Installation\n\n`gmmx` can be installed via pip:\n\n```bash\npip install gmmx\n```\n\n## Usage\n\n```python\nfrom gmmx import GaussianMixtureModelJax, EMFitter\n\n# Create a Gaussian Mixture Model with 16 components and 32 features\ngmm = GaussianMixtureModelJax.create(n_components=16, n_features=32)\n\n# Draw samples from the model\nn_samples = 10_000\nx = gmm.sample(n_samples)\n\n# Fit the model to the data\nem_fitter = EMFitter(tol=1e-3, max_iter=100)\ngmm_fitted = em_fitter.fit(x=x, gmm=gmm)\n```\n\n## Why Gaussian Mixture models?\n\nWhat are Gaussian Mixture Models (GMM) useful for in the age of deep learning? GMMs might have come out of fashion for classification tasks, but they still\nhave a few properties that make them useful in certain scenarios:\n\n- They are universal approximators, meaning that given enough components they can approximate any distribution.\n- Their likelihood can be evaluated in closed form, which makes them useful for generative modeling.\n- They are rather fast to train and evaluate.\n\nOne of these applications is in the context of image reconstruction, where GMMs can be used to model the distribution and pixel correlations of local (patch based)\nimage features. This can be useful for tasks like image denoising or inpainting. One of these methods I have used them for is [Jolideco](https://github.com/jolideco/jolideco).\nSpeed up the training of O(10^6) patches was the main motivation for `gmmx`.\n\n## Benchmarks\n\nHere are some results from the benchmarks in the `benchmarks` folder comparing against Scikit-Learn. The benchmarks were run on a 2021 MacBook Pro with an M1 Pro chip.\n\n### Prediction\n\n| Time vs. Number of Components | Time vs. Number of Samples | Time vs. Number of Features |\n| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------- |\n| ![Time vs. Number of Components](docs/_static/time-vs-n-components-predict.png) | ![Time vs. Number of Samples](docs/_static/time-vs-n-samples-predict.png) | ![Time vs. Number of Features](docs/_static/time-vs-n-features-predict.png) |\n\nFor prediction the speedup is around 2x for varying number of components and features. For the number of samples the cross-over point is around O(10^4) samples.\n\n### Training Time\n\n| Time vs. Number of Components | Time vs. Number of Samples | Time vs. Number of Features |\n| --------------------------------------------------------------------------- | --------------------------------------------------------------------- | ----------------------------------------------------------------------- |\n| ![Time vs. Number of Components](docs/_static/time-vs-n-components-fit.png) | ![Time vs. Number of Samples](docs/_static/time-vs-n-samples-fit.png) | ![Time vs. Number of Features](docs/_static/time-vs-n-features-fit.png) |\n\nFor training the speedup is around 10x on the same architecture. However there is no guarantee that it will converge to the same solution as Scikit-Learn. But there are some tests in the `tests` folder that compare the results of the two implementations.\n",
"bugtrack_url": null,
"license": null,
"summary": "A minimal implementation of Gaussian Mixture Models in Jax",
"version": "0.1",
"project_urls": {
"Documentation": "https://adonath.github.io/gmmx/",
"Homepage": "https://adonath.github.io/gmmx/",
"Repository": "https://github.com/adonath/gmmx"
},
"split_keywords": [
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "566f7535e8536d59f95adc3010ef0fb6487e8262986ade256a03ecd03d61146a",
"md5": "b6c9166dc7d39c332c5f51f089c0654f",
"sha256": "0342da3d0ff4aa122d7210b57c3b4d3359d25f23771accc6688d85fc25f516e7"
},
"downloads": -1,
"filename": "gmmx-0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b6c9166dc7d39c332c5f51f089c0654f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 3576,
"upload_time": "2024-12-18T14:56:28",
"upload_time_iso_8601": "2024-12-18T14:56:28.697351Z",
"url": "https://files.pythonhosted.org/packages/56/6f/7535e8536d59f95adc3010ef0fb6487e8262986ade256a03ecd03d61146a/gmmx-0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "15e5b1d7be3bf8ef27126d3d2a5612120ce344db4dfa8eedf3014b2432be6b8f",
"md5": "93d9b457336636535db5069e67bfcc72",
"sha256": "9b77473cc7c2624ecc2c5e17d1d947e8c1b6870b5517cef75f4a1a1135a44f7d"
},
"downloads": -1,
"filename": "gmmx-0.1.tar.gz",
"has_sig": false,
"md5_digest": "93d9b457336636535db5069e67bfcc72",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 5633,
"upload_time": "2024-12-18T14:56:30",
"upload_time_iso_8601": "2024-12-18T14:56:30.977893Z",
"url": "https://files.pythonhosted.org/packages/15/e5/b1d7be3bf8ef27126d3d2a5612120ce344db4dfa8eedf3014b2432be6b8f/gmmx-0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-18 14:56:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "adonath",
"github_project": "gmmx",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "gmmx"
}