Suggestions For frequent_patterns API

139 views
Skip to first unread message

Jarad C

unread,
Sep 22, 2017, 11:18:19 AM9/22/17
to mlxtend

Hey Sebastian. I'm a big fan. I was happy to learn today about frequent_patterns apriori and association_rules. I've been doing market basket analysis in R (in fact, it's the only thing I use R for). The arules package has some really useful tools for visualizing the data via arulesViz. My suggestions to enhance MLxtend frequent_patterns would be to:

1. Add frequent_patterns.plot_associations(df, ...) . Idea is to replicate the associations between items (itemsets?) I don't have super-clear roadmap on how to make a plot such as the one below using libraries that don't require a bunch of additional dependencies. This is more of a whimsical "I wish MLxtend had this!" kind of suggestion.


2. In R, you can plot what they call "LHS" vs "RHS". On the LHS (Left Hand Side) you can graph the relationship between "Product X" (ie: some product in your products list) to that of other products. This is achieved in R with "appearance" parameter.


ruleplot <- apriori(products, parameter=list(support=0.001, confidence=0.05, minlen=2), appearance=list(default="rhs", lhs="Product X"), control=list(verbose=FALSE))


3. Add frequent_patterns.item_frequency_plot(products, top_n=20, ...) shows a bar plot showing the most frequent products.

4. Arules has a is.redundant function used to remove redundant rules. This could maybe be a built-in keyword argument in frequent_patterns.association_rules(... remove_redundant=False) or a separate class / method / function.

Sebastian Raschka

unread,
Sep 23, 2017, 1:40:39 AM9/23/17
to Jarad C, mlxtend
Thanks for the suggestion, Jarad.

I think that such visualization capabilities would be tremendously helpful! Although, I currently don't know how to accomplish this exactly, I think that an GraphViz and pydot approach could potentially be used. Also, I don't have any reservations against adding additional dependencies if these are only required by a certain plotting function for this particular purpose. For example, like scikit-learn handles it for visualizing decision trees: http://scikit-learn.org/stable/modules/tree.html#classification

I would be happy to have this on the radar, and it would be nice if you could add this suggestion to the issue tracker!

Best,
Sebastian



> On Sep 22, 2017, at 11:18 AM, Jarad C <jnsco...@gmail.com> wrote:
>
> Hey Sebastian. I'm a big fan. I was happy to learn today about frequent_patterns apriori and association_rules. I've been doing market basket analysis in R (in fact, it's the only thing I use R for). The arules package has some really useful tools for visualizing the data via arulesViz. My suggestions to enhance MLxtend frequent_patterns would be to:
>
> 1. Add frequent_patterns.plot_associations(df, ...) . Idea is to replicate the associations between items (itemsets?) I don't have super-clear roadmap on how to make a plot such as the one below using libraries that don't require a bunch of additional dependencies. This is more of a whimsical "I wish MLxtend had this!" kind of suggestion.
>
>
>
>
>
> 2. In R, you can plot what they call "LHS" vs "RHS". On the LHS (Left Hand Side) you can graph the relationship between "Product X" (ie: some product in your products list) to that of other products. This is achieved in R with "appearance" parameter.
>
>
>
> ruleplot <- apriori(products, parameter=list(support=0.001, confidence=0.05, minlen=2), appearance=list(default="rhs", lhs="Product X"), control=list(verbose=FALSE))
>
>
> 3. Add frequent_patterns.item_frequency_plot(products, top_n=20, ...) shows a bar plot showing the most frequent products.
>
> 4. Arules has a is.redundant function used to remove redundant rules. This could maybe be a built-in keyword argument in frequent_patterns.association_rules(... remove_redundant=False) or a separate class / method / function.
>
> --
> You received this message because you are subscribed to the Google Groups "mlxtend" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mlxtend+u...@googlegroups.com.
> To post to this group, send email to mlx...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/mlxtend/042630ba-81f0-430a-a1b4-30f201e731e2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages