spmviz.measures.continuation#

spmviz.measures.continuation(db, pattern, constraints=None, include_end=True, occurrence='first', normalize=True)[source]#

Distribution of the element that follows an occurrence of a pattern.

Parameters:
dbSequenceDatabase
patternpattern
constraintsConstraints, optional

Constraints of the occurrence (e.g. Constraints(max_gap=1) for contiguous patterns).

include_endbool

Count the end of the sequence as the outcome END ("$").

occurrence{“first”, “all”}

Use the earliest-ending occurrence per sequence or every occurrence end.

normalizebool

Return probabilities instead of counts.

Returns:
pandas.Series

Indexed by item (and "$"), sorted decreasingly. Items of a next element with several items share its unit weight.

Examples

>>> db = SequenceDatabase(["abc", "abd", "ab", "acd"])
>>> continuation(db, "a b").to_dict()
{'c': 0.3333333333333333, 'd': 0.3333333333333333, '$': 0.3333333333333333}