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

*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.*minimum periodicity

## 2. Related work

The problem of frequent itemset mining is defined as follows. Let * I*be a set of items (symbols). A

*is a set of transactions*transaction database

*called its Tid. For example, consider the database of Table 1 , which will be used as running example. This database contains seven transactions (*c

*and*a, b, c, d

*appear in this transaction. The support of an itemset*e

*in a database*X

*is denoted as*D

*(*s

*) and defined as*X

*(*g

*) is defined as the set of transactions containing*X

*. Let there be any total order*X

*. The*I

*of an itemset*extensions

*are the itemsets that can be obtained by appending an item*X

*to*y

*such that*X

*consists of discovering the frequent itemsets [1]. An itemset*problem of frequent itemset mining

*is a*X

*if its support*frequent itemset

*(*s

*) is no less than a user-specified minimum support threshold*X

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

*. The set of transactions containing*X

*is denoted as*X

*if there does not exist a transaction*consecutive with respect to X

*of two consecutive transactions*period

*is a list of periods defined as*periods of an itemset X

*is defined as*X

*is a periodic frequent pattern (PFP) if*X

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

*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*k

## 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 asa v g p e r ( X ) = ∑ g ∈ p s ( X ) / | p s ( 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 asa v g p e r ( 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

*. The minimum periodicity is defined as*X

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 ifm i n A v g ≤ a v g p e r ( X ) ≤ m a x A v g ,m i n p e r ( X ) ≥ m i n P e r , andm a x p e r ( X ) ≤ m a x P e r , wherem i n A v g ,m a x A v g

As an example, assume that

Itemset | () | () | () | () |
---|---|---|---|---|

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 thatX ⊂ Y . It follows thata v g p e r ( Y ) ≥ a v g p e r ( X )

** Lemma 3 (Monotonicity of the minimum periodicity)**:

*.*Let X and Y be itemsets such thatX ⊂ Y . It follows thatm i n p e r ( Y ) ≥ m i n p e r ( X )

** Lemma 4 (Monotonicity of the maximum periodicity)**:

*.*Let X and Y be itemsets such thatX ⊂ Y . It follows thatm a x p e r ( Y ) ≥ m a x p e r ( X ) [9 ]

** Theorem 1 (Maximum periodicity pruning)**: Let

*be an itemset appearing in a database*X

*and its supersets are not PFPs if*D. X

*and all its supersets can be discarded. (This follows from Lemma 4.)*X

** Theorem 2 (Average periodicity pruning)**: Let

*be an itemset appearing in a database*X

*is not a PFP as well as all of its supersets if*D. X

*and all its supersets can be discarded.*X

## 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

*in a database*X

*is defined as the set of transactions*D

*. In the proposed algorithm, the tid-list of an itemset*X

*is further annotated with two values:*X

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

*meaning that*Pz

*was previously obtained by appending an item*Pz

*to*z

*,*P, γ

*of*Px

*. In this loop, the average periodicity of*P

*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*Px

*, and*γ

*should be explored (by Theorems 1 and 2). This is performed by merging*Px

*with all extensions*Px

*of*Py

*such that*P

*containing*Pxy

*is then constructed by calling the*Pxy

*, and*P, Px

*. 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*Py

*to explore its extension(s). The*Pxy

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*γ

*procedure. During the loop, if it is found that*Intersection

*cannot have no more than*Pxy

## 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

*data sets contain anonymized customer transactions from retail stores, while the*foodmart

*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*mushroom

*represent the number of transactions, distinct items, and average transaction length of a data set. Characteristics of the four data sets are*A

*(*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*γ

*represents the PFPM algorithm with*PFPM V-W-X

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

*and*mushroom

*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*chainstore

*. 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*γ

*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*foodmart

*and*retail

*data sets, depending on parameter values. For example, on*foodmart

*and*retail

## 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.