mhahsler / arules

Mining Association Rules and Frequent Itemsets with R
http://mhahsler.github.io/arules
GNU General Public License v3.0
194 stars 42 forks source link

Create a transaction class from a data frame with customer id and time stamp #26

Closed isaac2lord closed 7 years ago

isaac2lord commented 7 years ago

Am sorry I am new to arules package and this is not actually an issue but rather a question. I already posted this question on stackoverflow but wanted to ask it here hoping to get an answer quick.

I have a data set with customer ID, event_date, and event_type looking like this:

cid  event_date  event_type
451  2017-01-05  VSLS
451  2017-01-08  VCRD
451  2017-02-04  COMM
451  2017-02-05  COMM
...
564  2017-01-05  VSVC
564  2017-01-06  COMM
564  2017-02-05  VCRD
...

and wanted to analyze frequent pattern of events. Q is how I build a transaction class that could potentially include customer id and time stamp in its @itemsetInfo?

Thnx

mhahsler commented 7 years ago

Have a look at the following man page ? transactions. The last example shows exactly how to create transactions for data that looks like yours. The cid will be automatically added as the transactionID. To also add the timestamp to the itemset info, you can use the methods itemsetInfo after you have created the transaction object. However, you can only have a timestamp per transaction and your data has multiple event dates for each customer. Maybe it is useful to use the timestamp for the earliest or latest transaction (depending on the goal of your analysis).