Convolutional dictionary learning for noisy signals
Project description
This is a library to perform shift-invariant sparse dictionary learning, also known as convolutional sparse coding (CSC), on time-series data. It includes a number of different models:
univariate CSC
multivariate CSC
multivariate CSC with a rank-1 constraint [1]
univariate CSC with an alpha-stable distribution [2]
A mathematical descriptions of these models is available in the documentation.
Installation
To install this package, the easiest way is using pip. It will install this package and its dependencies. The setup.py depends on numpy and cython for the installation so it is advised to install them beforehand. To install this package, please run one of the two commands:
(Latest stable version)
pip install numpy cython
pip install alphacsc
(Development version)
pip install numpy cython
pip install git+https://github.com/alphacsc/alphacsc.git#egg=alphacsc
If you do not have admin privileges on the computer, use the --user flag with pip. To upgrade, use the --upgrade flag provided by pip.
To check if everything worked fine, you can run:
python -c 'import alphacsc'
and it should not give any error messages.
Quickstart
Here is an example to present briefly the API:
import numpy as np
import matplotlib.pyplot as plt
from alphacsc import BatchCDL
# Define the different dimensions of the problem
n_atoms = 10
n_times_atom = 50
n_channels = 5
n_trials = 10
n_times = 1000
# Generate a random set of signals
X = np.random.randn(n_trials, n_channels, n_times)
# Learn a dictionary with batch algorithm and rank1 constraints.
cdl = BatchCDL(n_atoms, n_times_atom, rank1=True)
cdl.fit(X)
# Display the learned atoms
fig, axes = plt.subplots(n_atoms, 2, num="Dictionary")
for k in range(n_atoms):
axes[k, 0].plot(cdl.u_hat_[k])
axes[k, 1].plot(cdl.v_hat_[k])
axes[0, 0].set_title("Spatial map")
axes[0, 1].set_title("Temporal map")
for ax in axes.ravel():
ax.set_xticklabels([])
ax.set_yticklabels([])
plt.show()
Bug reports
Use the github issue tracker to report bugs.
Cite our work
If you use this code in your project, please consider citing our work:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file alphacsc-0.2.2.tar.gz
.
File metadata
- Download URL: alphacsc-0.2.2.tar.gz
- Upload date:
- Size: 5.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/36.4.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6e2ce1198e2e011fde2f0faa76f545122452379685b3593377f7694f1d4fc17 |
|
MD5 | ce60c9d9487d3698ba53cee177b3280f |
|
BLAKE2b-256 | 69eed9ab886f431141431f3d27f0f2622d97689272fc94802f2ca977ade4b21d |