Skip to main content

MDLA - Multivariate Dictionary Learning Algorithm

Build Status Code style: black codecov

Dictionary Learning for the multivariate dataset

This dictionary learning variant is tailored for dealing with multivariate datasets and especially timeseries, where samples are matrices and the dataset is seen as a tensor. Dictionary Learning Algorithm (DLA) decompose input vector on a dictionary matrix with a sparse coefficient vector, see (a) on figure below. To handle multivariate data, a first approach called multichannel DLA, see (b) on figure below, is to decompose the matrix vector on a dictionary matrix but with sparse coefficient matrices, assuming that a multivariate sample could be seen as a collection of channels explained by the same dictionary. Nonetheless, multichannel DLA breaks the "spatial" coherence of multivariate samples, discarding the column-wise relationship existing in the samples. Multivariate DLA, (c), on figure below, decompose the matrix input on a tensor dictionary, where each atom is a matrix, with sparse coefficient vectors. In this case, the spatial relationship are directly encoded in the dictionary, as each atoms has the same dimension than an input samples.

dictionaries

(figure from Chevallier et al., 2014 )

To handle timeseries, two major modifications are brought to DLA:

  1. extension to multivariate samples
  2. shift-invariant approach, The first point is explained above. To implement the second one, there is two possibility, either slicing the input timeseries into small overlapping samples or to have atoms smaller than input samples, leading to a decomposition with sparse coefficients and offsets. In the latter case, the decomposition could be seen as sequence of kernels occuring at different time steps.

shift invariance

(figure from Smith & Lewicki, 2005)

The proposed implementation is an adaptation of the work of the following authors:

  • Q. Barthélemy, A. Larue, A. Mayoue, D. Mercier, and J.I. Mars. Shift & 2D rotation invariant sparse coding for multi- variate signal. IEEE Trans. Signal Processing, 60:1597–1611, 2012.
  • Q. Barthélemy, A. Larue, and J.I. Mars. Decomposition and dictionary learning for 3D trajectories. Signal Process., 98:423–437, 2014.
  • Q. Barthélemy, C. Gouy-Pailler, Y. Isaac, A. Souloumiac, A. Larue, and J.I. Mars. Multivariate temporal dictionary learning for EEG. Journal of Neuroscience Methods, 215:19–28, 2013.

Dependencies

The only dependencies are scikit-learn, matplotlib, numpy and scipy.

No installation is required.

Example

A straightforward example is:

import numpy as np
from mdla import MultivariateDictLearning
from mdla import multivariate_sparse_encode
from numpy.linalg import norm

rng_global = np.random.RandomState(0)
n_samples, n_features, n_dims = 10, 5, 3
X = rng_global.randn(n_samples, n_features, n_dims)

n_kernels = 8
dico = MultivariateDictLearning(n_kernels=n_kernels, max_iter=10).fit(X)
residual, code = multivariate_sparse_encode(X, dico)
print ('Objective error for each samples is:')
for i in range(len(residual)):
    print ('Sample', i, ':', norm(residual[i], 'fro') + len(code[i]))

Bibliography

Release files for mdla 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mdla 1.0.2
File Size Uploaded
mdla-1.0.2.tar.gz 32.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mdla 1.0.2
File Interpreter ABI Platform
mdla-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 63.4 kB

Release files / mdla-1.0.2.tar.gz

Download URL mdla-1.0.2.tar.gz
Size 32.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6a64948ccac93d0c611630fe354daf337fd404c0c8f70fe7402a774ff1d31273
BLAKE2b-256 checksum
How to use checksums
ea11bf51b51ec91c5bd0eb8ca78cbcac38f2afff52491c43bea4d3154a36bcae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.7.11 Darwin/20.6.0

Release files / mdla-1.0.2-py3-none-any.whl

Download URL mdla-1.0.2-py3-none-any.whl
Size 31.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2c13d1649e1e7809ddc581f7545e466cec756e17eb229695ceee121e9c259e2
BLAKE2b-256 checksum
How to use checksums
2b9f6ab2b806308c836074901578904c95f15eadefc8820baa5f347e26fea422
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.7.11 Darwin/20.6.0

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page