O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the market basket transaction file

We are almost there! There is an extra step that we need to do in order to prepare our data for market basket analysis.

The association rules package requires that the data be in transaction format. Transactions can either be specified in two different formats:

  1. One transaction per itemset with an identifier and this shows the entire basket in one line, just as we saw with the Groceries data.
  2. One single item per line with an identifier.

Additionally, you can create the actual transaction file in two different ways, by either:

  1. Physically writing a transactions file.
  2. Coercing a dataframe to transaction format.

For smaller amounts of data, coercing the dataframe to a transaction file is simpler, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required