{"id":20116686,"url":"https://github.com/sylvchev/mdla","last_synced_at":"2025-05-06T14:30:32.987Z","repository":{"id":45260420,"uuid":"41037112","full_name":"sylvchev/mdla","owner":"sylvchev","description":"Multivariate Dictionary Learning Algorithm","archived":false,"fork":false,"pushed_at":"2024-01-15T06:00:22.000Z","size":756,"stargazers_count":23,"open_issues_count":6,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-24T16:40:11.308Z","etag":null,"topics":["dictionary-learning","eeg","manifold","multivariate-dictionaries"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sylvchev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-08-19T13:50:46.000Z","updated_at":"2025-01-23T05:57:11.000Z","dependencies_parsed_at":"2023-02-01T02:00:43.824Z","dependency_job_id":"220e1697-6107-4ebf-91ac-c2be9953007c","html_url":"https://github.com/sylvchev/mdla","commit_stats":{"total_commits":194,"total_committers":3,"mean_commits":64.66666666666667,"dds":0.1701030927835051,"last_synced_commit":"87e7d6cb1515c7548fddd03f763e9605252eaff2"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sylvchev%2Fmdla","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sylvchev%2Fmdla/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sylvchev%2Fmdla/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sylvchev%2Fmdla/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sylvchev","download_url":"https://codeload.github.com/sylvchev/mdla/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252703215,"owners_count":21790851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dictionary-learning","eeg","manifold","multivariate-dictionaries"],"created_at":"2024-11-13T18:42:51.831Z","updated_at":"2025-05-06T14:30:32.615Z","avatar_url":"https://github.com/sylvchev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MDLA - Multivariate Dictionary Learning Algorithm\n\n[![Build Status](https://github.com/sylvchev/mdla/workflows/Test-and-Lint/badge.svg)](https://github.com/sylvchev/mdla/actions?query=branch%3Amaster)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![codecov](https://codecov.io/gh/sylvchev/mdla/branch/master/graph/badge.svg?token=Vba6g9c5pM)](https://codecov.io/gh/sylvchev/mdla)\n\n## Dictionary Learning for the multivariate dataset\n\nThis dictionary learning variant is tailored for dealing with multivariate datasets and\nespecially timeseries, where samples are matrices and the dataset is seen as a tensor.\nDictionary Learning Algorithm (DLA) decompose input vector on a dictionary matrix with a\nsparse coefficient vector, see (a) on figure below. To handle multivariate data, a first\napproach called **multichannel DLA**, see (b) on figure below, is to decompose the matrix\nvector on a dictionary matrix but with sparse coefficient matrices, assuming that a\nmultivariate sample could be seen as a collection of channels explained by the same\ndictionary. Nonetheless, multichannel DLA breaks the \"spatial\" coherence of multivariate\nsamples, discarding the column-wise relationship existing in the samples. **Multivariate\nDLA**, (c), on figure below, decompose the matrix input on a tensor dictionary, where each\natom is a matrix, with sparse coefficient vectors. In this case, the spatial relationship\nare directly encoded in the dictionary, as each atoms has the same dimension than an input\nsamples.\n\n![dictionaries](https://github.com/sylvchev/mdla/raw/master/img/multidico.png)\n\n(figure from [Chevallier et al., 2014](#biblio) )\n\nTo handle timeseries, two major modifications are brought to DLA:\n\n1. extension to **multivariate** samples\n2. **shift-invariant** approach, The first point is explained above. To implement the\n   second one, there is two possibility, either slicing the input timeseries into small\n   overlapping samples or to have atoms smaller than input samples, leading to a\n   decomposition with sparse coefficients and offsets. In the latter case, the\n   decomposition could be seen as sequence of kernels occuring at different time steps.\n\n![shift invariance](https://github.com/sylvchev/mdla/raw/master/img/audio4spikegram.png)\n\n(figure from [Smith \u0026 Lewicki, 2005](#biblio))\n\nThe proposed implementation is an adaptation of the work of the following authors:\n\n- Q. Barthélemy, A. Larue, A. Mayoue, D. Mercier, and J.I. Mars. _Shift \u0026 2D rotation\n  invariant sparse coding for multi- variate signal_. IEEE Trans. Signal Processing,\n  60:1597–1611, 2012.\n- Q. Barthélemy, A. Larue, and J.I. Mars. _Decomposition and dictionary learning for 3D\n  trajectories_. Signal Process., 98:423–437, 2014.\n- Q. Barthélemy, C. Gouy-Pailler, Y. Isaac, A. Souloumiac, A. Larue, and J.I. Mars.\n  _Multivariate temporal dictionary learning for EEG_. Journal of Neuroscience Methods,\n  215:19–28, 2013.\n\n## Dependencies\n\nThe only dependencies are scikit-learn, matplotlib, numpy and scipy.\n\nNo installation is required.\n\n## Example\n\nA straightforward example is:\n\n```python\nimport numpy as np\nfrom mdla import MultivariateDictLearning\nfrom mdla import multivariate_sparse_encode\nfrom numpy.linalg import norm\n\nrng_global = np.random.RandomState(0)\nn_samples, n_features, n_dims = 10, 5, 3\nX = rng_global.randn(n_samples, n_features, n_dims)\n\nn_kernels = 8\ndico = MultivariateDictLearning(n_kernels=n_kernels, max_iter=10).fit(X)\nresidual, code = multivariate_sparse_encode(X, dico)\nprint ('Objective error for each samples is:')\nfor i in range(len(residual)):\n    print ('Sample', i, ':', norm(residual[i], 'fro') + len(code[i]))\n```\n\n## \u003ca id=\"biblio\"\u003e\u003c/a\u003eBibliography\n\n- Chevallier, S., Barthelemy, Q., \u0026 Atif, J. (2014). [_Subspace metrics for multivariate\n  dictionaries and application to EEG_][1]. In Acoustics, Speech and Signal Processing\n  (ICASSP), IEEE International Conference on (pp. 7178-7182).\n- Smith, E., \u0026 Lewicki, M. S. (2005). [_Efficient coding of time-relative structure using\n  spikes_][2]. Neural Computation, 17(1), 19-45\n- Chevallier, S., Barthélemy, Q., \u0026 Atif, J. (2014). [_On the need for metrics in\n  dictionary learning assessment_][3]. In European Signal Processing Conference (EUSIPCO),\n  pp. 1427-1431.\n\n[1]: http://dx.doi.org/10.1109/ICASSP.2014.6854993 \"Chevallier et al., 2014\"\n[2]: http://dl.acm.org/citation.cfm?id=1119614 \"Smith and Lewicki, 2005\"\n[3]: https://hal-uvsq.archives-ouvertes.fr/hal-01352054/document\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsylvchev%2Fmdla","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsylvchev%2Fmdla","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsylvchev%2Fmdla/lists"}