SlideShare a Scribd company logo
1 of 25
Download to read offline
バスケット分析
相関マイニング - 技術編 -



   Karubi Namuru
   Sep 26th, 2010
自己紹介


●
    Karubi Namuru
●
    博士(理学)
●
    Twitter: @karubi
●
    Facebook:
    http://facebook.com/karubi
●
    出身:広島 , 居住:東京 , Seongnam
今日の内容

●
    バスケット分析とはなにか
●
    どのようなときに有効か
●
    どのように分析しているのか
●
    基本的な手順
    ●
        アプリオリアルゴリズム
    ●
        FPGrowth
バスケット分析とはなにか

●
    顧客が購入するものについて,「一緒に買われる商品」の組み
    合わせを発見するための分析
    ●
        顧客はさまざまな時間に,さまざまな量の,さまざまな商
        品を組み合わせて購入する
●
    アソシエーションルール
    ●
        データの傾向
    ●
        大量に蓄積している POS データや EC サイトのトランザ
        クションデータを使う
どのようなときに有効か

●
    たとえば,おむつを買う顧客は同時にビールも買う
    ●
        併売商品の選定
    ●
        商品陳列レイアウト
        –   両方の商材を近くに陳列しておくほうが顧客ニーズを満
            たす
        –   両方の商材をあえて離して陳列して,店舗内の回遊をう
            ながす
    ●
        などなど
どのように分析しているのか

●
    データの3つのレベル
    ●
        顧客
    ●
        アイテムセット
    ●
        品目
どのように分析しているのか

デジタルカメラと液晶を保護するためのシートを購入する顧
客は,メモリカードも一緒に買う傾向がある




{デジタルカメラ,液晶保護シート}⇒{メモリカード}




       { X }⇒{ Y }
基本的な手順

●
    全アイテムから全てのルールを洗い出す
●
    全アイテムからk個を選ぶ
●
    この全通りについて,意味のあるルールを見つける
    ●
        このアイテムの各々が前提にくるか,結論にくるかで分け
        方が変わる
    ●
        全アイテムが前提に集まる場合と,全アイテムが結論に集
        まる場合はルールにならないので排除する
価値のあるルール

●
    a 種類のアイテムにおいて存在するルールの数
       a

      ∑
      b=2
            
            a b
            b
               2 −2

    a 個のなかから b 個を選ぶ方法
                         a
●
                         
                         b
●
    b 個について,各々が前提になるか,または結論になるかのわけ
        b
    方 2
●
    全部が前提に集まるか,または結論に集まる場合についてはルー
    ルにならないので排除する 2b −2
価値のあるルール 続

●
    価値のあるルールの数:わずかな数
    ●
        価値のないルールの数:多数(取るにたらない,説明不能)
        →  効率よく探す必要がある
ある食料品店の例

●
    以下のような POS トランザクションがある



      顧客   アイテム
      1    オレンジジュース,炭酸飲料
      2    牛乳,オレンジジュース,ガラスクリーナー
      3    オレンジジュース,洗剤
      4    オレンジジュース,洗剤,炭酸飲料
      5    ガラスクリーナー,炭酸飲料
ある食料品店の例

●
    商品が同時に購入された数をかぞえてみる

       オレンジ   ガラスク   牛乳   炭酸飲料   洗剤
       ジュース   リーナ
オレンジ     4
ジュース
ガラスク     1     2
リーナ
牛乳       1     1      1
炭酸飲料     2     1      0    3
洗剤       1     0      0    1      2
ある食料品店の例

●
    オレンジジュースと炭酸飲料は,他の 2 アイテムよりも一緒に
    買われやすい
●
    洗剤はガラスクリーナや牛乳とは一緒に買われない
●
    牛乳は炭酸飲料や洗剤とは一緒に買われない
ある食料品店の例

●
    意味のあるルールかどうか
    ●
        5つのトランザクションのうち,2つで炭酸飲料とオレン
        ジジュースが一緒に出てくる
         → この2つのトランザクションがルールを支援している
          support = 2/5 (40%)
    ●
        炭酸飲料を含む3つのトランザクションのうち,2つがオ
        レンジジュースをふくんでいる
         → 炭酸飲料を買えば,オレンジジュースも買う
          confidence = 2/3(66.6%)
ある食料品店の例

●
    意味のあるルールかどうか

     →   confidence と support が大きいルール
ある食料品店の例

●
    炭酸飲料の購買を前提とした場合としない場合の,オレンジ
    ジュースが出現する倍率
    ●
        炭酸飲料とオレンジジュースを同時に購入するトランザク
        ションは2つ
    ●
        オレンジジュースを含むトランザクションは4つ
        –   リフト値  2/4 ( 0.5 )
        –   リフト値が1より大きい場合は,結果を前提としてほう
            が割合が出現割合が大きくなる
アプリオリアルゴリズム

●
    それぞれ,最小 confidence と,最小 support のふたつを与
    えて,各々のアイテムセットについて,与えられた最小
    conficende と,最小 support より,それぞれの値が大きい
    アソシエーションルールを発見する方法



                support  X ∪Y α
          support  X ∪Y / support  X  β
アプリオリアルゴリズム

1.  support ( X ∪ Y ) > α を満たすアイテムセットをすべて探し出
  し,それぞれのサポートを計算する

2.  support ( X ∪ Y ) / support ( X ) > β を満たすルールをさがす
アプリオリアルゴリズム


                              {1,3,4}
                              {2,4,5}
                              {2,4,6}

●
    全アイテムのサポートを求める
●
    各アイテムセットのサポートを求める

    {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 3}, {2, 4}, {2, 5}, {3, 4}
    {3, 5}, {4, 5}
●
    {2, 4} は 0.66
FPGrowth アルゴリズム

●
    アプリオリアルゴリズムの効率を改善するアルゴリズム
●
    アプリオリアルゴリズムは全通りについて計算をする必要が
    あったが, FPGrowth は FP-Tree という木構造に圧縮し
    て, FP-Tree からルールを抽出する.
●
    FP-Growth は途中経過に候補となるアイテムセットを生成し
    ないため,アイテムセット全体を対象に計算することを抑える
    ことができる.

    → つまり,アプリオリより高速にアソシエーションルールを抽
    出することができる.
FPGrowth アルゴリズム

●
    データ全体から全てのアイテムセットの support を計算
●
    頻出ではないアイテムセットを削除
●
    F をサポートの降順にソートする
●
    データベースをスキャンして, FP-Tree を作る
    ●
        ルートのラベルは null
    ●
        各ノードは(アイテム名, Count ,次のリンク)
    ●
        ヘッダテーブルは(アイテム名,ノードとのリンク)
FPGrowth アルゴリズム

                 {1,3,4}
                 {2,4,5}
                 {2,4,6}


サポート降順に  {4,2,1,3,5,6}     root



                     4
                            4
                     2
                     1
                            1     2
                     3
                     5
                     6      3     5   6
FPGrowth アルゴリズム

●
    Conditional Pattern Base に分割
    ●
        3 を含む集合
    ●
        1 を含んで3を含まない集合             root

    ●
        4を含んで,1と3を含まない集合
                           4
                                    4
                           2
                           1
                                    1     2
                           3
                           5
                           6        3     5   6
Mahout


PFPGrowth                   Parallel FP Growth Driver Class.

ParallelFPGrowthCombiner    takes each group of dependent transactions
                            and compacts it in a TransactionTree
                            structure
ParallelFPGrowthMapper      maps each transaction to all unique items
                            groups in the transaction.

ParallelFPGrowthReducer     takes each group of transactions and runs
                            Vanilla FPGrowth on it and outputs the the To
                            K frequent Patterns for each group.
まとめ

●
    バスケット分析の概要
●
    アルゴリズム
    ●
        アプリオリ
    ●
        FP-Growth


●
    ご質問は
        @karubi or gogokarubi@gmail.com まで

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

相関マイニング(バスケット分析)

  • 2. 自己紹介 ● Karubi Namuru ● 博士(理学) ● Twitter: @karubi ● Facebook: http://facebook.com/karubi ● 出身:広島 , 居住:東京 , Seongnam
  • 3. 今日の内容 ● バスケット分析とはなにか ● どのようなときに有効か ● どのように分析しているのか ● 基本的な手順 ● アプリオリアルゴリズム ● FPGrowth
  • 4. バスケット分析とはなにか ● 顧客が購入するものについて,「一緒に買われる商品」の組み 合わせを発見するための分析 ● 顧客はさまざまな時間に,さまざまな量の,さまざまな商 品を組み合わせて購入する ● アソシエーションルール ● データの傾向 ● 大量に蓄積している POS データや EC サイトのトランザ クションデータを使う
  • 5. どのようなときに有効か ● たとえば,おむつを買う顧客は同時にビールも買う ● 併売商品の選定 ● 商品陳列レイアウト – 両方の商材を近くに陳列しておくほうが顧客ニーズを満 たす – 両方の商材をあえて離して陳列して,店舗内の回遊をう ながす ● などなど
  • 6. どのように分析しているのか ● データの3つのレベル ● 顧客 ● アイテムセット ● 品目
  • 8. 基本的な手順 ● 全アイテムから全てのルールを洗い出す ● 全アイテムからk個を選ぶ ● この全通りについて,意味のあるルールを見つける ● このアイテムの各々が前提にくるか,結論にくるかで分け 方が変わる ● 全アイテムが前提に集まる場合と,全アイテムが結論に集 まる場合はルールにならないので排除する
  • 9. 価値のあるルール ● a 種類のアイテムにおいて存在するルールの数 a ∑ b=2  a b b  2 −2 a 個のなかから b 個を選ぶ方法 a ●   b ● b 個について,各々が前提になるか,または結論になるかのわけ b 方 2 ● 全部が前提に集まるか,または結論に集まる場合についてはルー ルにならないので排除する 2b −2
  • 10. 価値のあるルール 続 ● 価値のあるルールの数:わずかな数 ● 価値のないルールの数:多数(取るにたらない,説明不能) →  効率よく探す必要がある
  • 11. ある食料品店の例 ● 以下のような POS トランザクションがある 顧客 アイテム 1 オレンジジュース,炭酸飲料 2 牛乳,オレンジジュース,ガラスクリーナー 3 オレンジジュース,洗剤 4 オレンジジュース,洗剤,炭酸飲料 5 ガラスクリーナー,炭酸飲料
  • 12. ある食料品店の例 ● 商品が同時に購入された数をかぞえてみる オレンジ ガラスク 牛乳 炭酸飲料 洗剤 ジュース リーナ オレンジ 4 ジュース ガラスク 1 2 リーナ 牛乳 1 1 1 炭酸飲料 2 1 0 3 洗剤 1 0 0 1 2
  • 13. ある食料品店の例 ● オレンジジュースと炭酸飲料は,他の 2 アイテムよりも一緒に 買われやすい ● 洗剤はガラスクリーナや牛乳とは一緒に買われない ● 牛乳は炭酸飲料や洗剤とは一緒に買われない
  • 14. ある食料品店の例 ● 意味のあるルールかどうか ● 5つのトランザクションのうち,2つで炭酸飲料とオレン ジジュースが一緒に出てくる → この2つのトランザクションがルールを支援している support = 2/5 (40%) ● 炭酸飲料を含む3つのトランザクションのうち,2つがオ レンジジュースをふくんでいる → 炭酸飲料を買えば,オレンジジュースも買う confidence = 2/3(66.6%)
  • 15. ある食料品店の例 ● 意味のあるルールかどうか →   confidence と support が大きいルール
  • 16. ある食料品店の例 ● 炭酸飲料の購買を前提とした場合としない場合の,オレンジ ジュースが出現する倍率 ● 炭酸飲料とオレンジジュースを同時に購入するトランザク ションは2つ ● オレンジジュースを含むトランザクションは4つ – リフト値  2/4 ( 0.5 ) – リフト値が1より大きい場合は,結果を前提としてほう が割合が出現割合が大きくなる
  • 17. アプリオリアルゴリズム ● それぞれ,最小 confidence と,最小 support のふたつを与 えて,各々のアイテムセットについて,与えられた最小 conficende と,最小 support より,それぞれの値が大きい アソシエーションルールを発見する方法 support  X ∪Y α support  X ∪Y / support  X  β
  • 18. アプリオリアルゴリズム 1.  support ( X ∪ Y ) > α を満たすアイテムセットをすべて探し出 し,それぞれのサポートを計算する 2.  support ( X ∪ Y ) / support ( X ) > β を満たすルールをさがす
  • 19. アプリオリアルゴリズム {1,3,4} {2,4,5} {2,4,6} ● 全アイテムのサポートを求める ● 各アイテムセットのサポートを求める {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 3}, {2, 4}, {2, 5}, {3, 4} {3, 5}, {4, 5} ● {2, 4} は 0.66
  • 20. FPGrowth アルゴリズム ● アプリオリアルゴリズムの効率を改善するアルゴリズム ● アプリオリアルゴリズムは全通りについて計算をする必要が あったが, FPGrowth は FP-Tree という木構造に圧縮し て, FP-Tree からルールを抽出する. ● FP-Growth は途中経過に候補となるアイテムセットを生成し ないため,アイテムセット全体を対象に計算することを抑える ことができる. → つまり,アプリオリより高速にアソシエーションルールを抽 出することができる.
  • 21. FPGrowth アルゴリズム ● データ全体から全てのアイテムセットの support を計算 ● 頻出ではないアイテムセットを削除 ● F をサポートの降順にソートする ● データベースをスキャンして, FP-Tree を作る ● ルートのラベルは null ● 各ノードは(アイテム名, Count ,次のリンク) ● ヘッダテーブルは(アイテム名,ノードとのリンク)
  • 22. FPGrowth アルゴリズム {1,3,4} {2,4,5} {2,4,6} サポート降順に  {4,2,1,3,5,6} root 4 4 2 1 1 2 3 5 6 3 5 6
  • 23. FPGrowth アルゴリズム ● Conditional Pattern Base に分割 ● 3 を含む集合 ● 1 を含んで3を含まない集合 root ● 4を含んで,1と3を含まない集合 4 4 2 1 1 2 3 5 6 3 5 6
  • 24. Mahout PFPGrowth Parallel FP Growth Driver Class. ParallelFPGrowthCombiner takes each group of dependent transactions and compacts it in a TransactionTree structure ParallelFPGrowthMapper maps each transaction to all unique items groups in the transaction. ParallelFPGrowthReducer takes each group of transactions and runs Vanilla FPGrowth on it and outputs the the To K frequent Patterns for each group.
  • 25. まとめ ● バスケット分析の概要 ● アルゴリズム ● アプリオリ ● FP-Growth ● ご質問は @karubi or gogokarubi@gmail.com まで