R for Marketing Research and Analytics

Chris Chapman and Elea McDonnell Feit
February 2016

Chapter 12: Association Rules

Website for all data files:
http://r-marketing.r-forge.r-project.org/data.html

Brief introduction

Association rule mining looks for associations among events and data points, especially in data where absolute frequencies are low.

Some examples include:

  • Associations between items sold (where any given transaction usually purchases 0 of any specific item)
  • Associations between individuals and items
  • Associations between demographic characteristics and other behaviors such as purchase
  • Associations between interventions (where there is a large set) and behaviors
  • Recommendation engines deriving recommendations from any of the above

In shopping contexts, this is often known as market basket analysis.

Fundamental concepts

A transaction is a set of discrete data points (e.g., an item sold) that go together. For example, a transaction might be {hot dog, mustard, relish, cola}.

A rule is the conditional relationship of item sets. E.g.,: {hog dog, mustard} \rightarrow {relish, cola}. It only implies relationship, not causation.

The goal is to find rules where the association is higher than predicted by independent frequencies … in other words, lift. This involves:

support(SET): the proportion of transactions that contain SET. For example, support(hot dog, relish)=0.05.

confidence(RULE): the proportion of times that items on the right hand side of a rule occur, relative to the left hand side. For example: confidence(relish \rightarrow hot dog)=0.50. {hot dog} appears in 50% of the transactions where {relish} appears.

Lift

lift(RULE) is the support for a joint RULE relative to the multiplied support of its parts taken separately. For example, suppose:

  • support(relish) = 0.01 (relish sold in 1% of transactions)
  • support(hot dog) = 0.01 (hot dog sold in 1% of transactions)
  • support(relish, hot dog) = 0.005 (relish + hot dog sold in 0.5% of transactions)

Then:

  • lift(relish \rightarrow hot dog) = 0.005 / (0.01 * 0.01) = 50

This says the odds of seeing a transaction containg a hot dog alongside relish is 50x greater that one would expect if the two items were independent.

Discussion

Association rules are perhaps best viewed as an exploratory method. They generally do not express:

  • Confidence intervals needed for inference
  • Causation (although can be easily misunderstood as such)

Metrics such as lift are prone to overfitting in single samples. So, if you want to draw inferences from association rules, consider careful iteration and model testing with multiple samples (e.g., in-store test).

Meanwhile, they can be quite useful to generate hypotheses and to view data relationships in new ways.

Q&A and a break!

Notes

This presentation is based on Chapter 12 of Chapman and Feit, R for Marketing Research and Analytics © 2015 Springer.

All code in the presentation is licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Reference for supermarket data, used with permission:

Brijs, T., Swinnen, G., Vanhoof, K., & Wets, G. (1999). “Using association rules for product assortment decisions: A case study.” In Proceedings of the Fifth ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (pp. 254–260), Association for Computing Machinery.