Machine Learning with R Cookbook - Second Edition
by AshishSingh Bhatia, Yu-Wei, Chiu (David Chiu)
How it works...
Before mining frequent itemsets or using the association rule, it is important to prepare the dataset by the class of transactions. In this recipe, we will demonstrate how to transform a dataset from a list, matrix, and DataFrame format to transactions. In the first step, we generate the dataset in a list format containing three vectors of purchase records. Then, after we have assigned a transaction ID to each transaction, we transform the data into transactions using the as function.
Next, we demonstrate how to transform the data from the matrix format into transactions. To denote how items are purchased, one should use a binary incidence matrix to record the purchase behavior of each transaction with regard to different ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access