Skip to main content

Multivariate Dictionary Learning Algorithm

Project description

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

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

mdla-1.0.2.tar.gz (32.4 kB view details)

Uploaded Source

Built Distribution

mdla-1.0.2-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file mdla-1.0.2.tar.gz.

File metadata

  • Download URL: mdla-1.0.2.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.7.11 Darwin/20.6.0

File hashes

Hashes for mdla-1.0.2.tar.gz
Algorithm Hash digest
SHA256 6a64948ccac93d0c611630fe354daf337fd404c0c8f70fe7402a774ff1d31273
MD5 81236c6427522e8813d329bc20ce4095
BLAKE2b-256 ea11bf51b51ec91c5bd0eb8ca78cbcac38f2afff52491c43bea4d3154a36bcae

See more details on using hashes here.

File details

Details for the file mdla-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: mdla-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 31.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.7.11 Darwin/20.6.0

File hashes

Hashes for mdla-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b2c13d1649e1e7809ddc581f7545e466cec756e17eb229695ceee121e9c259e2
MD5 49c30e7459dd987f3ba2195491354b97
BLAKE2b-256 2b9f6ab2b806308c836074901578904c95f15eadefc8820baa5f347e26fea422

See more details on using hashes here.

Supported by

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