Frequent Representative Motif Miner (FRM-Miner): Efficiently Mining Frequent Representative Motifs in Large Collections of Time Series.
This repository contains the implementation of FRM-Miner as a Python package. By default, the C++ version is built and installed, but a pure Python implementation is provided as well.
It is easiest to install FRM-Miner via pip:
pip install frm-miner
This installs both the C++ and pure Python versions. The C++ implementation can then be imported with from frm import Miner
and the pure Python version can be imported with from frm._frm_py import Miner
.
You will probably get more meaningful results than this if you use your own data (collection of univariate time series, time series do not have to be equal length).
import numpy as np
import matplotlib.pyplot as plt # Not a dependency
from frm import Miner
# Set hyperparameters
MINSUP = 0.3
SEGLEN = 5
ALPHABET = 5
K = 4
# Generate 10 random time series with 100 observations each
rng = np.random.default_rng()
data = [rng.standard_normal(100) for _ in range(10)]
# Mine frequent representative motifs
miner = Miner(MINSUP, SEGLEN, ALPHABET, k=K)
motifs = miner.mine(data)
# Plot frequent representative motifs
fig, axs = plt.subplots(ncols=K, sharey='all', layout='compressed')
for motif, ax in zip(motifs, axs):
ax.plot(motif.representative)
plt.show()