8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pythonでfp-growthをやってみた

Posted at

そもそもの経緯

  • R使えない。てかなんか重くてつかたくない
  • 後々並列処理できたらいいなって思ってるし・・・
  • ということでむりやりpythonでやります

fp-growth

  • ちょっと研究でパターンマイニングをして集計したく、使う
  • ぐぐってもまぁー日本語少ない
  • ライブラリ探しの旅
  • んで出てきたのがこれ
  • https://github.com/evandempsey/fp-growth

READMEにあるやつをやる

まずはインストール

pip install pyfpgrowth

python起動して

>>> import pyfpgrowth                                                          
>>> transactions = [[1, 2, 5],                                                 
...                 [2, 4],                                                    
...                 [2, 3],                                                    
...                 [1, 2, 4],                                                 
...                 [1, 3],                                                    
...                 [2, 3],                                                    
...                 [1, 3],                                                    
...                 [1, 2, 3, 5],                                              
...                 [1, 2, 3]]                                                 
>>> patterns = pyfpgrowth.find_frequent_patterns(transactions, 2)              
>>> print patterns                                                             
{(1, 2): 4, (1, 2, 3): 2, (1, 3): 4, (1,): 6, (2,): 7, (2, 4): 2, (1, 5): 2, (5,): 2, (2, 3): 4, (2, 5): 2, (4,): 2, (1, 2, 5): 2} 

なんかぽいのでた。
でもなんか値がソートされてるのでてるし1→2と2→1を区別できないのかなぁって思った。

8
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?