| Title: | Discovery of Motifs in Spatial-Time Series |
|---|---|
| Description: | Allow to identify motifs in spatial-time series. A motif is a previously unknown subsequence of a (spatial) time series with relevant number of occurrences. For this purpose, the Combined Series Approach (CSA) is used. |
| Authors: | Heraldo Borges [aut, cre] (CEFET/RJ), Amin Bazaz [aut] (Polytech'Montpellier), Esther Pacciti [aut] (INRIA/Polytech'Montpellier), Eduardo Ogasawara [aut] (CEFET/RJ) |
| Maintainer: | Heraldo Borges <[email protected]> |
| License: | GPL-3 |
| Version: | 2.0.3 |
| Built: | 2026-05-28 06:41:04 UTC |
| Source: | https://github.com/heraldoborges/stmotif |
Performs the complete Combined Series Approach (CSA) workflow:
normalization with SAX encoding, motif discovery, and ranking.
This is a convenience wrapper around NormSAX,
SearchSTMotifs, and RankSTMotifs.
CSAMiningProcess(D, DS, w, a, sb, tb, si, ka)CSAMiningProcess(D, DS, w, a, sb, tb, si, ka)
D |
Dataset containing numeric values. |
DS |
Dataset containing SAX encoded values (recomputed internally; this parameter is kept for backward compatibility). |
w |
Word size (motif length in SAX symbols). |
a |
Number of letters in the SAX alphabet. |
sb |
Spatial block size (number of columns per block). |
tb |
Temporal block size (number of rows per block). |
si |
Minimum number of occurrences inside each block (sigma). |
ka |
Minimum number of spatial series with occurrences inside each block (kappa). |
A list of ranked motifs. Each motif contains:
Motif sequence in character format.
Matrix indicating which blocks contain this motif.
Data frame with columns s (spatial) and t
(temporal) giving the start positions of the motif in the original
dataset.
List with ranking components: dist, word,
qtd, proj.
D <- STMotif::example_dataset DS <- NormSAX(STMotif::example_dataset, 5) rmotif <- CSAMiningProcess(D, DS, 4, 5, 4, 10, 2, 2)D <- STMotif::example_dataset DS <- NormSAX(STMotif::example_dataset, 5) rmotif <- CSAMiningProcess(D, DS, 4, 5, 4, 10, 2, 2)
Displays the dataset as a heatmap (encoded via SAX binning) and overlays colored markers at the positions where the selected motifs occur.
display_motifsDataset(dataset, rstmotifs, alpha)display_motifsDataset(dataset, rstmotifs, alpha)
dataset |
Data frame or matrix containing numeric values. Each column represents a spatial series, each row a time point. |
rstmotifs |
List of ranked motifs, as returned by
|
alpha |
Integer. The cardinality of the SAX alphabet (number of discretization levels). |
A ggplot object showing the heatmap with
motif positions highlighted as colored squares.
D <- STMotif::example_dataset DS <- NormSAX(STMotif::example_dataset, 5) stmotifs <- SearchSTMotifs(D, DS, 4, 5, 4, 10, 2, 2) rstmotifs <- RankSTMotifs(stmotifs) display_motifsDataset( dataset = STMotif::example_dataset, rstmotifs[c(1:4)], 5 )D <- STMotif::example_dataset DS <- NormSAX(STMotif::example_dataset, 5) stmotifs <- SearchSTMotifs(D, DS, 4, 5, 4, 10, 2, 2) rstmotifs <- RankSTMotifs(stmotifs) display_motifsDataset( dataset = STMotif::example_dataset, rstmotifs[c(1:4)], 5 )
Displays the selected spatial-time series and highlights the segments corresponding to the discovered motifs using distinct colors.
display_motifsSTSeries(dataset, rstmotifs, space = seq_len(ncol(dataset)))display_motifsSTSeries(dataset, rstmotifs, space = seq_len(ncol(dataset)))
dataset |
Data frame or matrix containing numeric values. Each column represents a spatial series, each row a time point. |
rstmotifs |
List of ranked motifs, as returned by
|
space |
Integer vector specifying which columns (spatial series) to display. Defaults to all columns. |
A ggplot object showing the time series
with motif occurrences highlighted in color.
D <- STMotif::example_dataset DS <- NormSAX(STMotif::example_dataset, 5) stmotifs <- SearchSTMotifs(D, DS, 4, 5, 4, 10, 2, 2) rstmotifs <- RankSTMotifs(stmotifs) display_motifsSTSeries( dataset = STMotif::example_dataset, rstmotifs[c(1:4)], space = c(1:4, 10:12) )D <- STMotif::example_dataset DS <- NormSAX(STMotif::example_dataset, 5) stmotifs <- SearchSTMotifs(D, DS, 4, 5, 4, 10, 2, 2) rstmotifs <- RankSTMotifs(stmotifs) display_motifsSTSeries( dataset = STMotif::example_dataset, rstmotifs[c(1:4)], space = c(1:4, 10:12) )
A synthetic toy dataset containing 12 spatial-time series, each with 20 time points. Used to demonstrate the motif discovery functions in this package.
example_datasetexample_dataset
A data frame with 20 rows and 12 columns. Each column represents a spatial-time series and each row represents a time point. All values are numeric.
Synthetic data generated for demonstration purposes.
data(example_dataset) dim(example_dataset) # [1] 20 12data(example_dataset) dim(example_dataset) # [1] 20 12
Applies z-score normalization to the entire dataset and encodes
the values using the Symbolic Aggregate approXimation (SAX) with
an alphabet of size a.
NormSAX(D, a)NormSAX(D, a)
D |
Dataset containing numeric values. |
a |
Number of letters in the SAX alphabet. |
A data frame with the same dimensions as D, containing
SAX letter encodings (characters from a to the a-th
letter of the alphabet).
DS <- NormSAX(STMotif::example_dataset, 5)DS <- NormSAX(STMotif::example_dataset, 5)
Ranks the discovered motifs by computing a composite quality score that balances spatial-temporal proximity of occurrences, entropy of the SAX encoding, and quantity of occurrences.
RankSTMotifs(stmotifs)RankSTMotifs(stmotifs)
stmotifs |
List of identified motifs (as returned by
|
A list of motifs sorted by decreasing quality score. Each motif
gains a rank component with dist, word,
qtd, and proj values.
D <- STMotif::example_dataset DS <- NormSAX(STMotif::example_dataset, 5) stmotifs <- SearchSTMotifs(D, DS, 4, 5, 4, 10, 2, 2) rstmotifs <- RankSTMotifs(stmotifs)D <- STMotif::example_dataset DS <- NormSAX(STMotif::example_dataset, 5) stmotifs <- SearchSTMotifs(D, DS, 4, 5, 4, 10, 2, 2) rstmotifs <- RankSTMotifs(stmotifs)
Discovers motifs in the spatio-temporal blocks of the dataset, validates occurrence constraints, and groups motifs from neighboring blocks.
SearchSTMotifs(D, DS, w, a, sb, tb, si = 3, ka = 3)SearchSTMotifs(D, DS, w, a, sb, tb, si = 3, ka = 3)
D |
Dataset containing numeric values. |
DS |
Dataset containing SAX encoded values (as returned by
|
w |
Word size (motif length in SAX symbols). |
a |
Number of letters in the SAX alphabet. |
sb |
Spatial block size (number of columns per block). |
tb |
Temporal block size (number of rows per block). |
si |
Minimum number of occurrences inside each block (sigma). Default: 3. |
ka |
Minimum number of spatial series with occurrences inside each block (kappa). Default: 3. |
A list of identified motifs. Each motif contains:
Motif sequence in character format.
Matrix indicating which blocks contain this motif.
Data frame with columns s and t giving
the start positions in the original dataset.
D <- STMotif::example_dataset DS <- NormSAX(STMotif::example_dataset, 5) stmotifs <- SearchSTMotifs(D, DS, 4, 5, 4, 10, 2, 2)D <- STMotif::example_dataset DS <- NormSAX(STMotif::example_dataset, 5) stmotifs <- SearchSTMotifs(D, DS, 4, 5, 4, 10, 2, 2)
Adjusts the dimensions of a dataset so that it can be evenly divided
into spatio-temporal blocks of size tb x sb.
STSADatasetAdjust(D, tb, sb)STSADatasetAdjust(D, tb, sb)
D |
Dataset containing numeric values. |
tb |
Temporal block size (number of rows per block). |
sb |
Spatial block size (number of columns per block). |
Dataset with rows and columns trimmed to be divisible by
tb and sb, respectively.
D <- STSADatasetAdjust(STMotif::example_dataset, 20, 12)D <- STSADatasetAdjust(STMotif::example_dataset, 20, 12)