8.2 apriori quick start

20220112 Below we share examples of the various commands supported by the package. These should be repeatable out of the box with sample data available for download. The sample data is based on real analysis of courses (the items) undertaken by students (the baskets) within a Master of Computing degree. The sample data itself is fictional.

wget https://raw.githubusercontent.com/anusii/edsight/main/basket/mcomp.csv

Provide the dataset file as a command line argument:

ml itemsets apriori mcomp.csv

Or else pass the data into the command through a pipe:

cat mcomp.csv | ml itemsets apriori

Filter itemsets with support at least 0.2:

ml itemsets apriori --support 0.2 mcomp.csv

Or pipe the output to filter those itemsets of interest:

ml itemsets apriori mcomp.csv | mlr --csv filter '$support >= 0.2'

Build apriori association rules:

ml train apriori mcomp.csv

Filter the rules on their confidence:

ml train apriori --confidence 0.95 mcomp.csv

A second dataset illustrates basket analysis using a record of who has purchased various DVDs or movies.

wget https://raw.githubusercontent.com/anusii/edsight/main/basket/dvdtrans.csv

ml itemsets apriori dvdtrans.csv

ml train apriori --confidence=0.95 dvdtrans.csv


Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0