spmviz.patterns.PatternSet#
- class spmviz.patterns.PatternSet(patterns, support, sids=None, n_sequences=None, db=None, params=None)[source]#
Bases:
objectFrequent sequential patterns with their supports and supporting sequences.
- Parameters:
- patternsiterable
ofpatterns - supportarray_like
ofint Absolute supports \(\sigma(\varphi)\).
- sids
listofarray_like,optional Indices of the supporting sequences of each pattern.
- n_sequences
int,optional Size of the database (taken from
dbwhen given).- db
SequenceDatabase,optional The mined database; needed by analyses that look at the raw sequences.
- params
dict,optional Parameters of the mining run (algorithm, thresholds, constraints).
- patternsiterable
Examples
>>> import spmviz as sv >>> db = sv.SequenceDatabase(["abc", "abd", "acd", "bcd"]) >>> ps = sv.mine(db, min_support=0.5) >>> len(ps), ps.support_of("a c") (10, 2)
- confidence()[source]#
Extension confidence \(c(\varphi)=\sigma(\varphi)/\sigma(\pi(\varphi))\) (1 for single items).
- filter(min_support=None, min_length=None, max_length=None, starts_with=None, ends_with=None, contains=None, min_confidence=None, mask=None)[source]#
Select patterns by support, length, first/last item, contained items or confidence.
starts_with/ends_with/containstake an item or a list of items (forcontainsa pattern, matched as a subpattern).
- incidence(sparse=True)[source]#
Pattern–sequence incidence matrix \(\mathbf{T}\) (patterns in rows).
- measures(**kwargs)[source]#
All pattern measures (see
spmviz.measures.pattern_measures()).
- parents()[source]#
Index of the parent \(\pi(\varphi)\) of every pattern (-1 for single items or absent parents).
- roots()[source]#
Patterns without a parent in the set (the frequent single items when prefix-closed).
- rules(min_confidence=0.0, **kw)[source]#
Sequential rules
prefix ⇒ suffix(seespmviz.mining.sequential_rules()).
- property sids#
Supporting sequence indices of every pattern (computed from
dbif missing).
- sort(by='support', ascending=False)[source]#
Sorted copy;
byis"support","length","confidence","pattern"or a measure.
- to_frame(style='arrow')[source]#
One row per pattern: label, support, relative support, length, confidences, parent.