A transaction database.

## Abstract

Periodic pattern mining is the task of discovering patterns that periodically appear in transactions. Typically, periodic pattern mining algorithms will discard a pattern as being nonperiodic if it has a single period greater than a maximal periodicity threshold, defined by the user. A major drawback of this approach is that it is not flexible, as a pattern can be discarded based on only one of its periods. In this chapter, we present a solution to this issue by proposing to discover periodic patterns using three measures: the minimum periodicity, the maximum periodicity, and the average periodicity. The combination of these measures has the advantage of being more flexible. Properties of these measures are studied. Moreover, an efficient algorithm named PFPM (Periodic Frequent Pattern Miner) is proposed to discover all frequent periodic patterns using these measures. An experimental evaluation on real data sets shows that the proposed PFPM algorithm is efficient and can filter a huge number of nonperiodic patterns to reveal only the desired periodic patterns.

### Keywords

- frequent pattern mining
- periodic patterns
- periodicity measures

## 1. Introduction

In the field of data mining, frequent itemset mining (FIM) [1–3] is widely viewed as a fundamental task for discovering knowledge in databases. Given a transaction database, it consists of discovering sets of items frequently purchased by customers. Besides market basket analysis, FIM has many applications in other fields. Although numerous algorithms have been proposed for FIM [1–3], an inherent limitation of traditional FIM algorithms is that they are not designed to discover patterns that periodically appear in a database. Discovering periodic patterns has many applications such as to discover recurring customer purchase behavior. Several algorithms have been proposed to discover periodic frequent patterns (PFP) [4–9] in a transaction database (a sequence of transactions). Typically, periodic pattern mining algorithms will discard a pattern as being nonperiodic if it has a single period greater than a maximal periodicity threshold, defined by the user. A major drawback of this approach is that it is not flexible, as a pattern can be discarded based on only one of its periods. In this chapter, we propose a solution to this problem by discovering periodic patterns using three measures: the minimum periodicity, the maximum periodicity, and the average periodicity. This chapter has three main contributions. First, novel measures named *average periodicity* and *minimum periodicity* are proposed to assess the periodicity of patterns. Second, a fast algorithm named PFPM (Periodic Frequent Pattern Miner) is proposed to efficiently discover frequent periodic patterns using these measures. Third, we have conducted several experiments on real-life data sets to evaluate the efficiency of PFPM, and the usage of the novel periodicity measures. Experimental results show that the PFPM algorithm is efficient, and can filter a huge number of nonperiodic patterns to reveal only the desired periodic itemsets. The rest of this chapter is organized as follows. Sections 2, 3, 4, 5, and 6, respectively, present preliminaries related to FIM related work, the novel periodicity measures, the PFPM algorithm, the experimental evaluation, and the conclusion.

## 2. Related work

The problem of frequent itemset mining is defined as follows. Let *I* be a set of items (symbols). A *transaction database* is a set of transactions *c* called its Tid. For example, consider the database of Table 1 , which will be used as running example. This database contains seven transactions (*a, b, c, d* and *e* appear in this transaction. The support of an itemset *X* in a database *D* is denoted as *s*(*X*) and defined as *g*(*X*) is defined as the set of transactions containing *X*. Let there be any total order *I*. The *extensions* of an itemset *X* are the itemsets that can be obtained by appending an item *y* to *X* such that *problem of frequent itemset mining* consists of discovering the frequent itemsets [1]. An itemset *X* is a *frequent itemset* if its support *s*(*X*) is no less than a user-specified minimum support threshold

TID | Transaction | TID | Transaction | TID | Transaction | TID | Transaction |
---|---|---|---|---|---|---|---|

To discover frequent itemsets, various algorithms have been proposed such as Apriori [1], FP-Growth [10], LCM [2], and Eclat [3]. However, these algorithms are not designed to discover periodic patterns. Inspired by the work on FIM, researchers have designed several algorithms to discover periodic frequent patterns (PFP) in transaction databases [4–9]. Several applications of mining periodic frequent patterns have been reported in previous work [9].

A periodic frequent pattern is defined as follows [9]. Let there be a database *n* transactions, and an itemset *X*. The set of transactions containing *X* is denoted as *consecutive with respect to X* if there does not exist a transaction*period* of two consecutive transactions *periods of an itemset X* is a list of periods defined as *X* is defined as *X* is a periodic frequent pattern (PFP) if

The PFP-tree algorithm is the first algorithm that has been proposed for mining PFPs [9]. It utilizes a tree-based and pattern-growth approach for discovering PFPs, inspired by the FP-Growth algorithm [10]. Thereafter, an algorithm called MTKPP [4] was designed. It relies on a depth-first search and a vertical database representation. To use this algorithm, a user needs to set a parameter *k*. The algorithm then outputs the *k* most frequent PFPs in a database. Approximate algorithms for mining periodic patterns have also been developed. Ref. [5] mines PFPs by considering an approximation of the periodicities of patterns. Another approximate algorithm for PFP mining was recently proposed [8]. Other extensions of the PF-Tree algorithm named MIS-PF-tree [6] and MaxCPF [7] were respectively proposed to mine PFPs using multiple

## 3. Novel periodicity measures

To address the above limitation of traditional PFP mining algorithms, and provide a more flexible way of evaluating the periodicity of patterns, this chapter proposes the concept of *average periodicity*.

**Definition 1 (Average periodicity of an itemset)**: *The average periodicity of an itemset X is defined as avgper(X)=∑g∈ps(X)/|ps(X)| *.

For instance, the periods of the itemsets

**Lemma 1 (An alternative definition of the average periodicity)**: *Consider an itemset X. The average periodicity can also be calculated as avgper(X)=|D|/(|g(X)|+1) *.

The proof for that proposed lemma is omitted due to space limitations. This lemma is interesting because it shows that there is a relationship between the average periodicity and the support measure. Moreover, this lemma gives a second method for calculating the average periodicities of itemsets. An interesting observation is that if the term

The average periodicity is a very interesting measure since it measures the average period length of an itemset. However, this measure should always be considered with other measure. The reason is that the average periodicity does not consider if the period lengths vary widely. We illustrate this with an example. In the running example, the average periodicity of

The first measure is the *minimum periodicity* and it is used to filter out itemsets having short periods. Let there be an itemset *X*. The minimum periodicity is defined as

The second measure that we consider is the *maximum periodicity*, to avoid finding period patterns that do not occur for very long periods of time. This measure is defined as in Section 2 and is denoted as *X*.

In the following, we consider the minimum periodicity, maximum periodicity, and average periodicity measures to discover frequent periodic patterns as they let the user finely specify the type of periodic patterns to be found. But another reason for choosing these measures is that an algorithm can calculate them very efficiently. Consider an itemset *X*. The three measures can be calculated by browsing the list of transactions

**Definition 2 (Periodic frequent itemsets with novel measures)**: *An itemset X is said to be a periodic frequent itemset if and only if minAvg≤avgper(X)≤maxAvg , minper(X)≥minPer , and maxper(X)≤maxPer , where minAvg , maxAvg *,

As an example, assume that

Itemset | support s(X) | minper(X) | maxper(X) | avgper(X) |
---|---|---|---|---|

3 | 1 | 3 | 1.75 | |

3 | 1 | 3 | 1.75 | |

3 | 1 | 3 | 1.75 | |

3 | 1 | 3 | 1.75 | |

3 | 1 | 3 | 1.75 | |

3 | 1 | 3 | 1.75 | |

4 | 1 | 2 | 1.4 | |

4 | 1 | 2 | 1.4 | |

5 | 1 | 2 | 1.17 | |

4 | 1 | 3 | 1.4 | |

6 | 1 | 2 | 1.0 |

To develop an efficient algorithm for mining PFPs, it is important to design efficient pruning strategies. To use the periodicity measures for pruning the search space, the following theorems are presented. Proofs are omitted due to space limitations.

**Lemma 2 (Monotonicity of the average periodicity)**: *Let X and Y be itemsets such that X⊂Y . It follows that avgper(Y)≥avgper(X) *.

**Lemma 3 (Monotonicity of the minimum periodicity)**: *Let X and Y be itemsets such that X⊂Y . It follows that minper(Y)≥minper(X) *.

**Lemma 4 (Monotonicity of the maximum periodicity)**: *Let X and Y be itemsets such that X⊂Y . It follows that maxper(Y)≥maxper(X) [9]*.

**Theorem 1 (Maximum periodicity pruning)**: Let *X* be an itemset appearing in a database *D. X* and its supersets are not PFPs if *X* and all its supersets can be discarded. (This follows from Lemma 4.)

**Theorem 2 (Average periodicity pruning)**: Let *X* be an itemset appearing in a database *D. X* is not a PFP as well as all of its supersets if *X* and all its supersets can be discarded.

## 4. The PFPM algorithm

Based on the novel periodicity measures introduced in the previous sections, an efficient algorithm named PFPM (Periodic Frequent Pattern Miner) is proposed to efficiently discover periodic patterns using these measures. The proposed PFPM algorithm is a tid-list-based algorithm, inspired by the Eclat algorithm [3]. The *tid-list* of an itemset *X* in a database *D* is defined as the set of transactions *X*. In the proposed algorithm, the tid-list of an itemset *X* is further annotated with two values: *I* ^{* }of all items having a periodicity no greater than *γ* transactions (other items are ignored since they cannot be part of a PFP by Theorems 1 and 2. Items in

The *P* (initially assumed that *Pz* meaning that *Pz* was previously obtained by appending an item *z* to *P, γ*, *Px* of *P*. In this loop, the average periodicity of *Px* is calculated by dividing *Px* plus one (by Lemma 1). Then, if the average periodicity of *Px* is in the *Px* is no less/not greater than *Px* is a PFP and it is output. Then, if the number of elements in the tid-list of *Px* is no less than *γ*, and *Px* should be explored (by Theorems 1 and 2). This is performed by merging *Px* with all extensions *Py* of *P* such that *Pxy* containing *Pxy* is then constructed by calling the *P, Px*, and *Py*. This latter procedure is similar to the join of tid-list described in the Eclat algorithm [3], with the exception that periods are calculated during tid-list intersection to obtain *Pxy* to explore its extension(s). The

In the implementation of PFPM, two additional optimizations are included. The first optimization is to calculate the support of all pairs of items *Pxy* if *γ* by Theorem 2. The second optimization is in the *Intersection* procedure. During the loop, if it is found that *Pxy* cannot have no more than

## 5. Experimental study

To evaluate the performance of the proposed PFPM algorithm, we compared its performance with Eclat, a state-of-the-art algorithm for frequent itemset mining. The Eclat algorithm was chosen for comparison as the PFPM algorithm is based on Eclat. The PFPM and Eclat algorithms are implemented in Java. The experiment was carried out on a sixth generation 64 bit Core i5 processor running Windows 10, and equipped with 12 GB of free RAM. Four benchmark data sets were utilized in the experiment, which are commonly used in the FIM literature. The *retail, chainstore*, and *foodmart* data sets contain anonymized customer transactions from retail stores, while the *mushroom* data set is a dense benchmark data set. The data sets have been chosen because they represent the main types of data encountered in real-life scenarios (dense, sparse, and long transactions). Let *A* represent the number of transactions, distinct items, and average transaction length of a data set. Characteristics of the four data sets are *retail* (*mushroom* (*chainstore* (*foodmart* (*γ* value calculated by PPFM. Execution times, memory consumption, and number of patterns found were measured for each algorithm. All memory measurements were done using the Java API. For each data set, values for the periodicity thresholds have been found empirically for each data set (as they are data set specific), and were chosen to show the trade-off between the number of periodic patterns found and the execution time. Note that results for varying the *PFPM V-W-X* represents the PFPM algorithm with

It can first be observed that mining PFPs using PFPM is generally much faster than mining frequent itemsets. On the *retail* data set, PFPM is up to four times faster than Eclat. On the *mushroom* and *chainstore* data sets, no results are shown for Eclat because it cannot terminate within 1000 seconds or ran out of memory, while PFPM terminates in less than 10 seconds. The reason is that the search space is huge for these data sets when the minimum support is set to *γ*. The PFPM algorithm still terminates on these data sets because it only searches for periodic patterns, and thus prunes a large part of the search space containing nonperiodic patterns. On the *foodmart* data set, PFPM can be up to five times faster than Eclat depending on the parameters. But it can also be slightly slower in some cases. The reason is that *foodmart* is a sparse data set and thus the gain in terms of pruning the search space does not always offset the cost of calculating the periodicity measures. In general, the more the periodicity thresholds are restrictive, the more the gap between the runtime of Eclat and PFPM increases. A second observation is that the number of PFPs can be much less than the number of frequent itemsets (see Figure 2 ). This demonstrates that a huge amount of nonperiodic patterns are found in real-life data sets. Some of the patterns found are quite interesting as they contain several items. For example, it is found that items with product ids 32, 48, and 39 are periodically bought with an average periodicity of 16.32, a minimum periodicity of 1, and a maximum periodicity of 170. Memory consumption was also compared, although detailed results are not shown. It was observed that PFPM use up to four and five times less memory than Eclat on the *retail* and *foodmart* data sets, depending on parameter values. For example, on *retail* and

## 6. Conclusion

In this chapter, an efficient algorithm named PFPM (Periodic Frequent Pattern Miner) was proposed to efficiently discover all frequent periodic patterns using three periodicity measures (the minimum, average, and maximum periodicity). An experimental evaluation on real data sets shows that the proposed PFPM algorithm is efficient and can filter a huge number of nonperiodic patterns to reveal only the desired periodic patterns. Source code and data sets will be made available as part of the SPMF open source data mining library [11] http://www.philippe-fournier-viger.com/spmf/. For future work, we are working on mining correlated periodic patterns [12], and periodic high-utility itemsets [13].

## Acknowledgments

This publication has been created within the project support of VŠB-TUO activities with China with financial support from the Moravian-Silesian Region and partially was supported by the grant SGS reg. no. No. SP2016/170 conducted at VSB-Technical University of Ostrava, Czech Republic.