fp tree basics

Upload: swapnil-joshi

Post on 13-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 fp tree basics

    1/67

    11

    Data Mining:

    Concepts and Techniques(3rded.)

    Chapter 6

    Jiawei Han, Micheline Kamber, and Jian PeiUniversity of Illinois at Urbana-Champaign &

    Simon Fraser University

    2013 Han, Kamber & Pei. All rights reserved.

  • 7/27/2019 fp tree basics

    2/67

    March 9, 2014 Data Mining: Concepts and Techniques 2

  • 7/27/2019 fp tree basics

    3/67

    3

    Chapter 6: Mining Frequent Patterns, Association

    and Correlations: Basic Concepts and Methods

    Basic Concepts

    Frequent Itemset Mining Methods

    Which Patterns Are Interesting?Pattern

    Evaluation Methods

    Summary

  • 7/27/2019 fp tree basics

    4/67

    4

    What Is Frequent Pattern Analysis?

    Frequent pattern: a pattern (a set of items, subsequences, substructures,etc.) that occurs frequently in a data set

    First proposed by Agrawal, Imielinski, and Swami [AIS93] in the context

    of frequent itemsetsand association rule mining

    Motivation: Finding inherent regularities in data

    What products were often purchased together?Beer and diapers?!

    What are the subsequent purchases after buying a PC?

    What kinds of DNA are sensitive to this new drug?

    Can we automatically classify web documents?

    Applications

    Basket data analysis, cross-marketing, catalog design, sale campaign

    analysis, Web log (click stream) analysis, and DNA sequence analysis.

  • 7/27/2019 fp tree basics

    5/67

    5

    Why Is Freq. Pattern Mining Important?

    Freq. pattern: An intrinsic and important property ofdatasets

    Foundation for many essential data mining tasks

    Association, correlation, and causality analysis

    Sequential, structural (e.g., sub-graph) patterns

    Pattern analysis in spatiotemporal, multimedia, time-series, and stream data

    Classification: discriminative, frequent pattern analysis

    Cluster analysis: frequent pattern-based clustering

    Data warehousing: iceberg cube and cube-gradient

    Semantic data compression: fascicles

    Broad applications

  • 7/27/2019 fp tree basics

    6/67

    6

    Basic Concepts: Frequent Patterns

    itemset: A set of one or moreitems

    k-itemsetX = {x1, , xk}

    (absolute) support, or, support

    countof X: Frequency oroccurrence of an itemset X

    (relative)support, s, is thefraction of transactions thatcontains X (i.e., the probabilitythat a transaction contains X)

    An itemset X is frequentif Xssupport is no less than a minsupthreshold

    Customer

    buys diaper

    Customer

    buys both

    Customer

    buys beer

    Tid Items bought

    10 Beer, Nuts, Diaper

    20 Beer, Coffee, Diaper

    30 Beer, Diaper, Eggs

    40 Nuts, Eggs, Milk50 Nuts, Coffee, Diaper, Eggs, Milk

  • 7/27/2019 fp tree basics

    7/677

    Basic Concepts: Association Rules

    Find all the rules X Y with

    minimum support and confidence

    support, s, probabilitythat atransaction contains X Y

    confidence, c,conditionalprobabilitythat a transactionhaving X also contains Y

    Let minsup = 50%, minconf = 50%

    Freq. Pat.: Beer:3, Nuts:3, Diaper:4, Eggs:3,{Beer, Diaper}:3

    Customer

    buys

    diaper

    Customer

    buys both

    Customer

    buys beer

    Nuts, Eggs, Milk40

    Nuts, Coffee, Diaper, Eggs, Milk50

    Beer, Diaper, Eggs30

    Beer, Coffee, Diaper20

    Beer, Nuts, Diaper10

    Items boughtTid

    Association rules: (many more!) Beer Diaper (60%, 100%)

    Diaper

    Beer (60%, 75%)

  • 7/27/2019 fp tree basics

    8/678

    Closed Patterns and Max-Patterns

    A long pattern contains a combinatorial number of sub-patterns, e.g., {a1, , a100} contains (

    1001) + (

    1002) + +

    (110000) = 21001 = 1.27*1030 sub-patterns!

    Solution: Mine closed patternsand max-patternsinstead

    An itemset Xis closed if X is frequentand there exists nosuper-patternY X, with the same supportas X

    (proposed by Pasquier, et al. @ ICDT99)

    An itemset X is a max-patternif X is frequent and there

    exists no frequent super-pattern Y X (proposed by

    Bayardo @ SIGMOD98)

    Closed pattern is a lossless compression of freq. patterns

    Reducing the # of patterns and rules

  • 7/27/2019 fp tree basics

    9/679

    Closed Patterns and Max-Patterns

    Exercise: Suppose a DB contains only two transactions ,

    Let min_sup = 1

    What is the set of closed itemset?

    {a1, , a100}: 1

    {a1, , a50}: 2

    What is the set of max-pattern?

    {a1, , a100}: 1

    What is the set of all patterns?

    {a1}: 2, , {a1, a2}: 2, , {a1, a51}: 1, , {a1, a2, , a100}: 1

    A big number: 2100- 1? Why?

  • 7/27/2019 fp tree basics

    10/6710

    Chapter 5: Mining Frequent Patterns, Association

    and Correlations: Basic Concepts and Methods

    Basic Concepts

    Frequent Itemset Mining Methods

    Which Patterns Are Interesting?Pattern

    Evaluation Methods

    Summary

  • 7/27/2019 fp tree basics

    11/6711

    Scalable Frequent Itemset Mining Methods

    Apriori: A Candidate Generation-and-Test

    Approach

    Improving the Efficiency of Apriori

    FPGrowth: A Frequent Pattern-Growth Approach

    ECLAT: Frequent Pattern Mining with Vertical

    Data Format

  • 7/27/2019 fp tree basics

    12/6712

    The Downward Closure Property and Scalable

    Mining Methods

    The downward closureproperty of frequent patterns Any subset of a frequent itemset must be frequent

    If {beer, diaper, nuts}is frequent, so is {beer,diaper}

    i.e., every transaction having {beer, diaper, nuts} alsocontains {beer, diaper}

    Scalable mining methods: Three major approaches

    Apriori (Agrawal & Srikant@VLDB94)

    Freq. pattern growth (FPgrowthHan, Pei & Yin@SIGMOD00)

    Vertical data format approach (CharmZaki & Hsiao@SDM02)

  • 7/27/2019 fp tree basics

    13/6713

    Apriori: A Candidate Generation & Test Approach

    Apriori pruning principle: If there is anyitemset which is

    infrequent, its superset should not be generated/tested!

    (Agrawal & Srikant @VLDB94, Mannila, et al. @ KDD 94)

    Method: Initially, scan DB once to get frequent 1-itemset

    Generatelength (k+1) candidateitemsets from length k

    frequentitemsets

    Test the candidates against DB

    Terminate when no frequent or candidate set can be

    generated

  • 7/27/2019 fp tree basics

    14/6714

    The Apriori AlgorithmAn Example

    Database TDB

    1stscan

    C1L1

    L2

    C2 C22ndscan

    C3 L33rdscan

    Tid Items

    10 A, C, D

    20 B, C, E

    30 A, B, C, E

    40 B, E

    Itemset sup

    {A} 2

    {B} 3

    {C} 3

    {D} 1

    {E} 3

    Itemset sup{A} 2

    {B} 3

    {C} 3

    {E} 3

    Itemset

    {A, B}

    {A, C}

    {A, E}

    {B, C}

    {B, E}

    {C, E}

    Itemset sup

    {A, B} 1

    {A, C} 2

    {A, E} 1

    {B, C} 2

    {B, E} 3

    {C, E} 2

    Itemset sup

    {A, C} 2

    {B, C} 2

    {B, E} 3{C, E} 2

    Itemset

    {B, C, E}

    Itemset sup

    {B, C, E} 2

    Supmin= 2

  • 7/27/2019 fp tree basics

    15/6715

    The Apriori Algorithm (Pseudo-Code)

    Ck: Candidate itemset of size kLk: frequent itemset of size k

    L1= {frequent items};

    for(k= 1; Lk!=; k++) do beginCk+1= candidates generated from Lk;

    for eachtransaction tin database do

    increment the count of all candidates in Ck+1that

    are contained in tLk+1 = candidates in Ck+1with min_support

    end

    returnkLk;

  • 7/27/2019 fp tree basics

    16/6716

    Implementation of Apriori

    How to generate candidates?

    Step 1: self-joining Lk

    Step 2: pruning

    Example of Candidate-generation L3={abc, abd, acd, ace, bcd}

    Self-joining: L3*L3

    abcd from abcand abd

    acdefrom acdand ace

    Pruning:

    acdeis removed because adeis not in L3

    C4 = {abcd}

  • 7/27/2019 fp tree basics

    17/6719

    Candidate Generation: An SQL Implementation

    SQL Implementation of candidate generation Suppose the items in Lk-1are listed in an order

    Step 1: self-joining Lk-1

    insert intoCkselectp.item1, p.item2, , p.itemk-1, q.itemk-1

    from Lk-1p, Lk-1 qwherep.item1=q.item1, , p.itemk-2=q.itemk-2, p.itemk-1 66.7%.

    play basketball not eat cereal[20%, 33.3%] is more accurate,

    although with lower support and confidence

    Measure of dependent/correlated events: lift

    89.05000/3750*5000/3000

    5000/2000),( CBlift

    Basketball Not basketball Sum (row)

    Cereal 2000 1750 3750

    Not cereal 1000 250 1250

    Sum(col.) 3000 2000 5000

    )()(

    )(

    BPAP

    BAPlift

    33.15000/1250*5000/3000

    5000/1000),( CBlift

  • 7/27/2019 fp tree basics

    54/67

    56

    Are liftand 2 Good Measures of Correlation?

    Buy walnuts buymilk[1%, 80%] is

    misleading if 85% of

    customers buy milk

    Support and confidence

    are not good to indicate

    correlations

    Over 20 interestingness

    measures have been

    proposed (see Tan,Kumar, Sritastava

    @KDD02)

    Which are good ones?

    Null-Invariant Measures

  • 7/27/2019 fp tree basics

    55/67

    57

    Null Invariant Measures

  • 7/27/2019 fp tree basics

    56/67

    March 9, 2014 Data Mining: Concepts and Techniques 58

    Comparison of Interestingness Measures

    Milk No Milk Sum (row)

    Coffee m, c ~m, c c

    No Coffee m, ~c ~m, ~c ~c

    Sum(col.) m ~m

    Null-(transaction) invariance is crucial for correlation analysis Lift and 2are not null-invariant

    5 null-invariant measures

    Null-transactionsw.r.t. m and c Null-invariant

    Subtle: They disagree

    Kulczynskimeasure (1927)

  • 7/27/2019 fp tree basics

    57/67

    59

    Analysis of DBLP Coauthor Relationships

    Advisor-advisee relation: Kulc: high,coherence: low, cosine: middle

    Recent DB conferences, removing balanced associations, low sup, etc.

    Tianyi Wu, Yuguo Chen and Jiawei Han, Association Mining in LargeDatabases: A Re-Examination of Its Measures, Proc. 2007 Int. Conf.Principles and Practice of Knowledge Discovery in Databases(PKDD'07), Sept. 2007

    http://www.cs.uiuc.edu/~hanj/pdf/pkdd07_twu.pdfhttp://www.cs.uiuc.edu/~hanj/pdf/pkdd07_twu.pdfhttp://www.cs.uiuc.edu/~hanj/pdf/pkdd07_twu.pdfhttp://www.cs.uiuc.edu/~hanj/pdf/pkdd07_twu.pdfhttp://www.cs.uiuc.edu/~hanj/pdf/pkdd07_twu.pdfhttp://www.cs.uiuc.edu/~hanj/pdf/pkdd07_twu.pdf
  • 7/27/2019 fp tree basics

    58/67

    Which Null-Invariant Measure Is Better?

    IR (Imbalance Ratio): measure the imbalance of twoitemsets A and B in rule implications

    Kulczynski and Imbalance Ratio (IR) together present aclear picture for all the three datasets D4through D6 D4 is balanced & neutral

    D5 is imbalanced & neutral

    D6 is very imbalanced & neutral

    Chapter 5: Mining Frequent Patterns, Association

  • 7/27/2019 fp tree basics

    59/67

    61

    Chapter 5: Mining Frequent Patterns, Association

    and Correlations: Basic Concepts and Methods

    Basic Concepts

    Frequent Itemset Mining Methods

    Which Patterns Are Interesting?Pattern

    Evaluation Methods

    Summary

  • 7/27/2019 fp tree basics

    60/67

    62

    Summary

    Basic concepts: association rules, support-confident framework, closed and max-patterns

    Scalable frequent pattern mining methods

    Apriori (Candidate generation & test)

    Projection-based (FPgrowth, CLOSET+, ...)

    Vertical format approach (ECLAT, CHARM, ...)

    Which patterns are interesting?

    Pattern evaluation methods

  • 7/27/2019 fp tree basics

    61/67

    March 9, 2014 Data Mining: Concepts and Techniques 63

  • 7/27/2019 fp tree basics

    62/67

    64

    Ref: Basic Concepts of Frequent Pattern Mining

    (Association Rules) R. Agrawal, T. Imielinski, and A. Swami. Miningassociation rules between sets of items in large databases.

    SIGMOD'93.

    (Max-pattern) R. J. Bayardo. Efficiently mining long patterns from

    databases. SIGMOD'98.

    (Closed-pattern) N. Pasquier, Y. Bastide, R. Taouil, and L. Lakhal.

    Discovering frequent closed itemsets for association rules. ICDT'99.

    (Sequential pattern) R. Agrawal and R. Srikant. Mining sequential

    patterns. ICDE'95

  • 7/27/2019 fp tree basics

    63/67

    65

    Ref: Apriori and Its Improvements

    R. Agrawal and R. Srikant. Fast algorithms for mining association rules.

    VLDB'94.

    H. Mannila, H. Toivonen, and A. I. Verkamo. Efficient algorithms for

    discovering association rules. KDD'94.

    A. Savasere, E. Omiecinski, and S. Navathe. An efficient algorithm for

    mining association rules in large databases. VLDB'95.

    J. S. Park, M. S. Chen, and P. S. Yu. An effective hash-based algorithm

    for mining association rules. SIGMOD'95.

    H. Toivonen. Sampling large databases for association rules. VLDB'96.

    S. Brin, R. Motwani, J. D. Ullman, and S. Tsur. Dynamic itemsetcounting and implication rules for market basket analysis. SIGMOD'97.

    S. Sarawagi, S. Thomas, and R. Agrawal. Integrating association rule

    mining with relational database systems: Alternatives and implications.

    SIGMOD'98.

  • 7/27/2019 fp tree basics

    64/67

    66

    Ref: Depth-First, Projection-Based FP Mining

    R. Agarwal, C. Aggarwal, and V. V. V. Prasad. A tree projection algorithm for

    generation of frequent itemsets. J. Parallel and Distributed Computing:02.

    J. Han, J. Pei, and Y. Yin. Mining frequent patterns without candidate

    generation. SIGMOD 00.

    J. Liu, Y. Pan, K. Wang, and J. Han. Mining Frequent Item Sets by

    Opportunistic Projection. KDD'02. J. Han, J. Wang, Y. Lu, and P. Tzvetkov. Mining Top-K Frequent Closed

    Patterns without Minimum Support. ICDM'02.

    J. Wang, J. Han, and J. Pei. CLOSET+: Searching for the Best Strategies for

    Mining Frequent Closed Itemsets. KDD'03.

    G. Liu, H. Lu, W. Lou, J. X. Yu. On Computing, Storing and Querying Frequent

    Patterns. KDD'03.

    G. Grahne and J. Zhu, Efficiently Using Prefix-Trees in Mining Frequent

    Itemsets, Proc. ICDM'03 Int. Workshop on Frequent Itemset Mining

    Implementations (FIMI'03), Melbourne, FL, Nov. 2003

    R f V ti l F t d R E ti M th d

  • 7/27/2019 fp tree basics

    65/67

    67

    Ref: Vertical Format and Row Enumeration Methods

    M. J. Zaki, S. Parthasarathy, M. Ogihara, and W. Li. Parallel algorithmfor discovery of association rules. DAMI:97.

    Zaki and Hsiao. CHARM: An Efficient Algorithm for Closed Itemset

    Mining, SDM'02.

    C. Bucila, J. Gehrke, D. Kifer, and W. White. DualMiner: A Dual-

    Pruning Algorithm for Itemsets with Constraints. KDD02.

    F. Pan, G. Cong, A. K. H. Tung, J. Yang, and M. Zaki , CARPENTER:

    Finding Closed Patterns in Long Biological Datasets. KDD'03. H. Liu, J. Han, D. Xin, and Z. Shao, Mining Interesting Patterns from

    Very High Dimensional Data: A Top-Down Row Enumeration

    Approach, SDM'06.

  • 7/27/2019 fp tree basics

    66/67

  • 7/27/2019 fp tree basics

    67/67

    Ref: Freq. Pattern Mining Applications

    Y. Huhtala, J. Krkkinen, P. Porkka, H. Toivonen. EfficientDiscovery of Functional and Approximate Dependencies Using

    Partitions. ICDE98.

    H. V. Jagadish, J. Madar, and R. Ng. Semantic Compression and

    Pattern Extraction with Fascicles. VLDB'99. T. Dasu, T. Johnson, S. Muthukrishnan, and V. Shkapenyuk.

    Mining Database Structure; or How to Build a Data Quality

    Browser. SIGMOD'02.

    K. Wang, S. Zhou, J. Han. Profit Mining: From Patterns to Actions.EDBT02.