Git Product home page Git Product logo

mdla's Introduction

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

mdla's People

Contributors

dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.