View source: R/pat_prefix_span.R
| pat_prefix_span | R Documentation |
Frequent sequential pattern mining with PrefixSpan.
pat_prefix_span(
support = 0,
support_strategy = pat_support_threshold("min_count", min_count = 2),
minlen = 1,
maxlen = NULL,
maxsize = NULL,
mingap = NULL,
maxgap = NULL,
quality_filter = NULL
)
support |
minimum support threshold. If |
support_strategy |
support threshold strategy created with |
minlen |
minimum number of events per pattern |
maxlen |
maximum number of events per pattern ( |
maxsize |
maximum number of items per event ( |
mingap |
minimum gap between successive events ( |
maxgap |
maximum gap between successive events ( |
quality_filter |
optional quality filter created with |
PrefixSpan (Prefix-projected Sequential pattern mining) discovers frequent sequential
patterns – ordered lists of itemsets – by growing patterns one prefix at a time and
recursively mining the projected database of suffixes. A pattern grows by an i-extension
(adding an item to its last itemset) or an s-extension (appending a new itemset); the
support of a pattern is the fraction of input sequences in which it occurs in order.
maxlen bounds the number of itemsets, maxsize the items per itemset, and
mingap/maxgap constrain the time difference between consecutive matched events.
Sequences are given as a data frame with sequenceID, eventID and item columns, or
as a list of sequences (each a list of itemsets, or of list(time, items) events).
returns a pat_prefix_span object
Pei, J., Han, J., Mortazavi-Asl, B., Wang, J., Pinto, H., Chen, Q., Dayal, U., & Hsu, M. (2001). PrefixSpan: Mining Sequential Patterns Efficiently by Prefix-Projected Pattern Growth. ICDE, 215-224.
The canonical implementation is maintained in the Python pydaltoolbox port; this is a
backport of it.
seqs <- data.frame(
sequenceID = c(1,1,1,2,2,3),
eventID = c(10,20,20,10,20,10),
item = c("A","B","C","A","C","A")
)
pm <- pat_prefix_span(support = 0.5)
pm <- fit(pm, seqs)
seqs_found <- discover(pm, seqs)
evaluate(pm, seqs_found)$metrics
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.