I am a newbie in python & trying to run association rule using apriori algorithm. I have extensively done this operation using R. For the same my work-flow was;
- read the csv file (let df) in R
- create sparse/transaction matrix using 'acast' (
acast(df,colA~colB)
) - run apriori function choosing useful support lift & confidence
- inspect rules
For running arules in python, I searched & got to see here also I can execute the third step as I did in R. I am having problem for the second step.
What I did,searching Google,was,
import csv
file = open('file path',"rb")
csvread = csv.reader(file,delimiter=';')
Now from this 'csvread' I want to select two columns, let 'store-location' & 'item', & create a sparse matrix first, like I did in R (acast), & after that I want to run the apriori algorithm to inspect rules.
I have gone through several links but could not find the exact solution for the problem. Any suggestion that can solve my issue will be highly helpful.