Skip to content

vruetten/cmm

Repository files navigation

Coherence Mixture Model

License PyPI Python Version CI codecov

or for now k-Means Clustering with coherence as distance metric

Unsupervised clustering algoirthm which clusters timeseries based on coherence.

Coherence between two signals is defined as:

$$\mathcal{C}(\mathbf{\hat{x}}(\omega), \mathbf{\hat{\mu}}(\omega)) = \frac{|S_{x,\mu}(\omega)|^2}{S_{xx}(\omega)\cdot S_{\mu, \mu}(\omega)}$$

xnt: data
k: number of clusters
fs: sampling frequency
nperseg: number of timepoints in each trial (to compute FFT over and average)
itemax: max number of iterations to optimize

from cmm import CMM

cm = CMM(
    xnt,
    k=k,
    fs=fs,
    nperseg=nperseg,
)

cm.optimize(itemax=itemax)
print(cm.labels)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages