# Dictionary Learning Toolbox
Official documentation [here](https://unibuc.gitlab.io/graphomaly/dictionary-learning/).
This work was supported in part by the [Graphomaly Research Grant](http://graphomaly.upb.ro/)
and is based on the [Matlab Dictionary Learning Toolbox](https://gitlab.com/pirofti/dl-box)
that accompanied the Springer book mentioned bellow.
If you use our work in your research, please cite as:
B. Dumitrescu and P. Irofti, Dictionary Learning Algorithms and Applications, Springer, 2018
```
@book{DL_book,
author = {Dumitrescu, B. and Irofti, P.},
title = {Dictionary Learning Algorithms and Applications},
year = {2018},
publisher = {Springer},
}
```
## Installation and setup
Install via pip from the [PyPi repository](https://pypi.org/project/dictlearn/):
```
pip install dictlearn
```
or for the latest changes not yet in the official release:
```
pip install git+https://gitlab.com/unibuc/graphomaly/dictionary-learning
```
## Usage
The package follows the [sklearn](https://scikit-learn.org/) API and can be included in your projects via
```
from dictlearn import DictionaryLearning
```
which will provide you with a standard scikit-learn estimator that you can use in your pipeline.
### Example
```
import matplotlib.pyplot as plt
from dictlearn import DictionaryLearning
from sklearn.datasets import make_sparse_coded_signal
n_components = 50 # number of atoms
n_features = 20 # signal dimension
n_nonzero_coefs = 3 # sparsity
n_samples = 100 # number of signals
n_iterations = 20 # number of dictionary learning iterations
max_iter = 10
fit_algorithm = "aksvd"
transform_algorithm = "omp"
Y, D_origin, X_origin = make_sparse_coded_signal(
n_samples=n_samples,
n_components=n_components,
n_features=n_features,
n_nonzero_coefs=n_nonzero_coefs,
random_state=0
)
dl = DictionaryLearning(
n_components=n_components,
max_iter=max_iter,
fit_algorithm=fit_algorithm,
transform_algorithm=transform_algorithm,
n_nonzero_coefs=n_nonzero_coefs,
code_init=None,
dict_init=None,
verbose=False,
random_state=None,
kernel_function=None,
params=None,
data_sklearn_compat=False
)
dl.fit(Y)
plt.plot(range(max_iter), dl.error_, label=fit_algorithm)
plt.legend()
plt.show()
```
For configuration and tweaks please consult the [documentation](https://unibuc.gitlab.io/graphomaly/dictionary-learning/).
## Development and testing
First clone the repository and change directory to the root of your fresh checkout.
#### 0. Install Prerequisites
Install PyPA’s [build](https://packaging.python.org/en/latest/key_projects/#build):
```
python3 -m pip install --upgrade build
```
#### 1. Build
Inside the `dictonary-learning` directory
```
python -m build
```
#### 2. Virtual Environment
Create a virtual environment with Python:
```
python -m venv venv
```
Activate the environment:
```
source venv/bin/activate
```
For Windows execute instead:
```
venv\Scripts\activate
```
#### 3. Install
Inside the virutal environment execute:
```
pip install dist/dictlearn-*.whl
```
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/unibuc/graphomaly/dictionary-learning",
"name": "dictlearn",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "dictionary learning, sparse representations, machine learning, signal processing",
"author": "Paul Irofti, Denis Ilie-Ablachim, Bogdan Dumitrescu",
"author_email": "graphomaly@fmi.unibuc.ro",
"download_url": "https://files.pythonhosted.org/packages/04/da/bc4d470cc9cbd9f7f628049ded4e66bc4fe0dcf287f10fb56bd08969b236/dictlearn-0.2.2.tar.gz",
"platform": null,
"description": "# Dictionary Learning Toolbox\n\nOfficial documentation [here](https://unibuc.gitlab.io/graphomaly/dictionary-learning/).\n\nThis work was supported in part by the [Graphomaly Research Grant](http://graphomaly.upb.ro/)\nand is based on the [Matlab Dictionary Learning Toolbox](https://gitlab.com/pirofti/dl-box)\nthat accompanied the Springer book mentioned bellow.\n\nIf you use our work in your research, please cite as:\n\nB. Dumitrescu and P. Irofti, Dictionary Learning Algorithms and Applications, Springer, 2018\n```\n@book{DL_book,\nauthor = {Dumitrescu, B. and Irofti, P.},\ntitle = {Dictionary Learning Algorithms and Applications},\nyear = {2018},\npublisher = {Springer},\n}\n```\n\n## Installation and setup\nInstall via pip from the [PyPi repository](https://pypi.org/project/dictlearn/):\n```\npip install dictlearn\n```\n\nor for the latest changes not yet in the official release:\n```\npip install git+https://gitlab.com/unibuc/graphomaly/dictionary-learning\n```\n\n## Usage\n\nThe package follows the [sklearn](https://scikit-learn.org/) API and can be included in your projects via\n```\nfrom dictlearn import DictionaryLearning\n```\nwhich will provide you with a standard scikit-learn estimator that you can use in your pipeline.\n\n### Example\n\n```\nimport matplotlib.pyplot as plt\n\nfrom dictlearn import DictionaryLearning\nfrom sklearn.datasets import make_sparse_coded_signal\n\nn_components = 50 # number of atoms\nn_features = 20 # signal dimension\nn_nonzero_coefs = 3 # sparsity\nn_samples = 100 # number of signals\nn_iterations = 20 # number of dictionary learning iterations\n\nmax_iter = 10\nfit_algorithm = \"aksvd\"\ntransform_algorithm = \"omp\"\n\nY, D_origin, X_origin = make_sparse_coded_signal(\n n_samples=n_samples,\n n_components=n_components,\n n_features=n_features,\n n_nonzero_coefs=n_nonzero_coefs,\n random_state=0\n)\n\ndl = DictionaryLearning(\n n_components=n_components,\n max_iter=max_iter,\n fit_algorithm=fit_algorithm,\n transform_algorithm=transform_algorithm,\n n_nonzero_coefs=n_nonzero_coefs,\n code_init=None,\n dict_init=None,\n verbose=False,\n random_state=None,\n kernel_function=None,\n params=None,\n data_sklearn_compat=False\n)\n\ndl.fit(Y)\n\nplt.plot(range(max_iter), dl.error_, label=fit_algorithm)\nplt.legend()\nplt.show()\n```\n\nFor configuration and tweaks please consult the [documentation](https://unibuc.gitlab.io/graphomaly/dictionary-learning/).\n\n## Development and testing\n\nFirst clone the repository and change directory to the root of your fresh checkout.\n\n#### 0. Install Prerequisites\nInstall PyPA\u2019s [build](https://packaging.python.org/en/latest/key_projects/#build):\n```\npython3 -m pip install --upgrade build\n```\n\n#### 1. Build\nInside the `dictonary-learning` directory\n```\npython -m build\n```\n\n#### 2. Virtual Environment\n\nCreate a virtual environment with Python:\n```\npython -m venv venv\n```\n\nActivate the environment:\n```\nsource venv/bin/activate\n```\n\nFor Windows execute instead:\n```\nvenv\\Scripts\\activate\n```\n\n#### 3. Install\nInside the virutal environment execute:\n```\npip install dist/dictlearn-*.whl\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Dictionary Learning Toolbox",
"version": "0.2.2",
"project_urls": {
"Bug Tracker": "https://gitlab.com/unibuc/graphomaly/dictionary-learning/-/issues",
"Homepage": "https://gitlab.com/unibuc/graphomaly/dictionary-learning"
},
"split_keywords": [
"dictionary learning",
" sparse representations",
" machine learning",
" signal processing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9240c93857534fe8415025aa18373d02af734bcbb577d7f1254ae8b2088e57db",
"md5": "91ec48bf683b8fe05d163363e017ebf7",
"sha256": "afa92c83f6ec7d27f01c12fbeae91838aae29ab74b33b257697f852884a51835"
},
"downloads": -1,
"filename": "dictlearn-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "91ec48bf683b8fe05d163363e017ebf7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 55946,
"upload_time": "2024-04-09T10:28:45",
"upload_time_iso_8601": "2024-04-09T10:28:45.682207Z",
"url": "https://files.pythonhosted.org/packages/92/40/c93857534fe8415025aa18373d02af734bcbb577d7f1254ae8b2088e57db/dictlearn-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "04dabc4d470cc9cbd9f7f628049ded4e66bc4fe0dcf287f10fb56bd08969b236",
"md5": "196dfefe60e83036aabef179ad4a4ed0",
"sha256": "014391e31e9ed87e530a293a780411d41d9805ef306eac5e4cfa090e9fc10769"
},
"downloads": -1,
"filename": "dictlearn-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "196dfefe60e83036aabef179ad4a4ed0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 44859,
"upload_time": "2024-04-09T10:28:47",
"upload_time_iso_8601": "2024-04-09T10:28:47.186236Z",
"url": "https://files.pythonhosted.org/packages/04/da/bc4d470cc9cbd9f7f628049ded4e66bc4fe0dcf287f10fb56bd08969b236/dictlearn-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-09 10:28:47",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "unibuc",
"gitlab_project": "graphomaly",
"lcname": "dictlearn"
}