I tried fp-growth with python

In the first place

--R Cannot be used. I don't want to use it because it's heavy ――I wish I could do parallel processing later ... ――So I will do it with python

fp-growth ――I want to do pattern mining for a little research and aggregate it, so I use it ――There is little Japanese --A journey to find a library ――This is what came out

Do the one in the README

First install

pip install pyfpgrowth

Start 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} 

It was kind of like that. But the values are sorted, so I wondered if I couldn't distinguish between 1 → 2 and 2 → 1.

Recommended Posts

I tried fp-growth with python
I tried scraping with Python
I tried gRPC with Python
I tried scraping with python
I tried web scraping with python.
I tried running prolog with python 3.8.2.
I tried SMTP communication with Python
I tried scraping Yahoo News with Python
I tried Python> autopep8
I tried sending an email with python.
I tried non-photorealistic rendering with Python + opencv
I tried a functional language with Python
I tried recursion with Python ② (Fibonacci sequence)
I tried Python> decorator
#I tried something like Vlookup with Python # 2
I tried "smoothing" the image with Python + OpenCV
I tried hundreds of millions of SQLite with python
I tried "differentiating" the image with Python + OpenCV
I tried L-Chika with Raspberry Pi 4 (Python edition)
I tried Jacobian and partial differential with python
I tried to get CloudWatch data with Python
I tried using mecab with python2.7, ruby2.3, php7
I tried function synthesis and curry with python
I tried to output LLVM IR with Python
I tried "binarizing" the image with Python + OpenCV
I tried running faiss with python, Go, Rust
I tried to automate sushi making with python
I tried playing mahjong with Python (single mahjong edition)
I tried running Deep Floor Plan with Python 3.6.10.
I tried sending an email with SendGrid + Python
I tried Learning-to-Rank with Elasticsearch!
I made blackjack with python!
I tried clustering with PyCaret
I tried Python C extension
[Python] I tried using OpenPose
I made blackjack with Python.
I made wordcloud with Python.
I tried to implement Minesweeper on terminal with python
I tried to get started with blender python script_Part 01
I tried to touch the CSV file with Python
I tried to draw a route map with Python
[OpenCV / Python] I tried image analysis of cells with OpenCV
I tried to solve the soma cube with python
I tried to get started with blender python script_Part 02
I tried to implement an artificial perceptron with python
I tried to automatically generate a password with Python3
Mayungo's Python Learning Episode 1: I tried printing with print
I tried to solve the problem with Python Vol.1
I tried to analyze J League data with Python
I tried "morphology conversion" of images with Python + OpenCV
I tried hitting the API with echonest's python client
I tried to solve AOJ's number theory with Python
I tried to touch Python (installation)
I tried trimming efficiently with OpenCV
I can't install python3 with pyenv-vertualenv
I tried summarizing sentences with summpy
I tried machine learning with liblinear
I tried moving food with SinGAN
I made a fortune with Python.
I sent an SMS with Python
I tried implementing DeepPose with PyTorch