Classwork 11

Association Rules with Music Data

Author

Byeong-Hak Choe

Published

April 29, 2026

Modified

April 27, 2026

Setup

library(tidyverse)
library(rmarkdown)

library(arules)
library(arulesViz)
library(plotly)

🎧 Load the Music Transaction Data

path_music <- "https://bcdanl.github.io/data/music_old.tsv"

music_eg <- read.transactions(
  file = path_music,
  format = "single",
  header = TRUE,
  cols = c(1, 2),
  rm.duplicates = TRUE
)


1️⃣ Column and Row Labels

Question 1

What do the labels for the column and the row of music_eg represent?



2️⃣ Transaction Sizes

Question 2a

What are the first quartile, the median, the third quartile, and the maximum of transaction sizes in music_eg?


Question 2b

Visualize the distribution of transaction sizes.



3️⃣ Item Frequencies

Question 3a

  • Find the top 50 most frequently occurring items in music_eg.
  • Also find the top 50 least frequently occurring items in music_eg.


Question 3b

Visualize the distribution of item occurrence.



4️⃣ Association Rules

Before finding association rules, we subset the data to transactions with more than one artist.

basket_sizes <- size(music_eg)
musicbaskets_use <- music_eg[basket_sizes > 1]

Question 4a

From the subset of music_eg whose transaction size is greater than 1, find association rules with minimum support 0.01 and minimum confidence 0.5.


Question 4b

Pick one rule from Question 4a. Interpret the following qualities of the rule you pick:

  1. support
  2. confidence
  3. coverage
  4. lift
  5. count


Question 4c

Find at least 5 association rules for the item you pick by setting appropriate levels of minimum support and minimum confidence.



Discussion

Welcome to our Classwork 11 Discussion Board! πŸ‘‹

This space is designed for you to engage with your classmates about the material covered in Classwork 11.

Whether you are looking to delve deeper into the content, share insights, or have questions about the content, this is the perfect place for you.

If you have any specific questions for Byeong-Hak (@bcdanl) regarding the Classwork 11 materials or need clarification on any points, don’t hesitate to ask here.

All comments will be stored here.

Let’s collaborate and learn from each other!

Back to top