Data preparation
Our data preparation task involves taking the transactions data and converting it to a form where we have product pairs and their transaction frequency. Transaction frequency is the number of transactions in which both the products have appeared. We will use these product pairs to build our graph. The vertices of our graph are the products. For every product pair, an edge is drawn in the graph between the corresponding product vertices. The weight of the edge is the transaction frequency.
We will use the arules
package version 1.5-0 to help us perform this data preparation task:
> library(arules) > transactions.obj <- read.transactions(file = 'data.csv', format = "single", + sep = ",", + cols = c("order_id", "product_id"), + rm.duplicates = FALSE, + quote = "", skip = 0, + encoding...