Skip to main content

Mine Frequent Representative Motifs

Project description

FRM-Miner

Frequent Representative Motif Miner (FRM-Miner): Efficiently Mining Frequent Representative Motifs in Large Collections of Time Series.

Pipeline of FRM-Miner: A time series database is discretised into a sequence database using SAX. Non-overlapping frequent sequential patterns without gaps are mined, after which their occurrences are mapped back to the time series. The occurrences are then used to construct frequent representative motifs.

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.

Installation

It is easiest to install FRM-Miner via pip:

pip install frm-miner

This installs the pure Python version, which can be imported with from frm import Miner.

Alternatively, if you want to install the C++ version, clone this directory and change to it. Rename the file _setup.py to setup.py, then run

pip install .

A C++ compiler is needed for this, as well as a Python installation that includes the Python.h header files. After installation, the C++ implementation can be imported with from frm import Miner and the pure Python version can be imported with from frm._frm_py import Miner.

Example

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 in requirements

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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

frm-miner-0.0.7.tar.gz (15.8 kB view hashes)

Uploaded Source

Built Distribution

frm_miner-0.0.7-py3-none-any.whl (9.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page