Skip to main content

Dictionary Learning Toolbox

Project description

Dictionary Learning Toolbox

Official documentation here.

This work was supported in part by the Graphomaly Research Grant and is based on the Matlab Dictionary Learning Toolbox 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:

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 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.

Development and testing

First clone the repository and change directory to the root of your fresh checkout.

0. Install Prerequisites

Install PyPA’s 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dictlearn-0.2.2.tar.gz (44.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dictlearn-0.2.2-py3-none-any.whl (55.9 kB view details)

Uploaded Python 3

File details

Details for the file dictlearn-0.2.2.tar.gz.

File metadata

  • Download URL: dictlearn-0.2.2.tar.gz
  • Upload date:
  • Size: 44.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for dictlearn-0.2.2.tar.gz
Algorithm Hash digest
SHA256 014391e31e9ed87e530a293a780411d41d9805ef306eac5e4cfa090e9fc10769
MD5 196dfefe60e83036aabef179ad4a4ed0
BLAKE2b-256 04dabc4d470cc9cbd9f7f628049ded4e66bc4fe0dcf287f10fb56bd08969b236

See more details on using hashes here.

File details

Details for the file dictlearn-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: dictlearn-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 55.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for dictlearn-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 afa92c83f6ec7d27f01c12fbeae91838aae29ab74b33b257697f852884a51835
MD5 91ec48bf683b8fe05d163363e017ebf7
BLAKE2b-256 9240c93857534fe8415025aa18373d02af734bcbb577d7f1254ae8b2088e57db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page