Question: Please give me the code, articulation, analysis, and interpretation of this output. library(data.table) library(knitr) setwd(~/Documents/JerryS/) #music_data

Please give me the code, articulation, analysis, and interpretation of this output.

library(data.table) library(knitr) setwd("~/Documents/JerryS/") #music_data<-fread('lastfm-dataset-360K/usersha1-artmbid-artname-plays.tsv') #best_artists<-rev(sort(table(music_data$V3)))[1:104] #music_data<-music_data[V3 %in% names(best_artists),] #best_listeners<-rev(sort(table(music_data$V1)))[1:1000] #music_data<-music_data[V1 %in% names(best_listeners),] #save(music_data,file='music_data.rdata') # subsetted the data set to use the 104 most popular artists and the 1000 top listeners. The resulting dataset is loaded below. load('music_data.rdata')

Examine the rows in the file where you will see the names of the artists that were played on the radio by their fans.

head(music_data)

## V1 ## ## 1: 005613160b9c403fac90a2926c2df562b47ab276 ## 2: 005613160b9c403fac90a2926c2df562b47ab276 ## 3: 005613160b9c403fac90a2926c2df562b47ab276 ## 4: 005613160b9c403fac90a2926c2df562b47ab276 ## 5: 005613160b9c403fac90a2926c2df562b47ab276 ## 6: 005613160b9c403fac90a2926c2df562b47ab276 ## V2 V3 V4 ## ## 1: 10adbe5e-a2c0-4bf3-8249-2b4cbf6e6ca8 massive attack 647 ## 2: a74b1b7f-71a5-4011-9441-d0b5e4122711 radiohead 514 ## 3: 4a4ee089-93b1-4470-af9a-6ff575d32704 the prodigy 413 ## 4: 1946a82a-f927-40c2-8235-38d64f50d043 the chemical brothers 383 ## 5: e21857d5-3256-4547-afb3-4b6ded592596 gorillaz 342 ## 6: 9beb62b2-88db-4cea-801e-162cd344ee53 beastie boys 322

Use arules from R to employ the mining association rules.

library(arules)

Convert the data into a matrix so that each fan is a row that shows 0s and 1s for artists across the columns, producing an R object. This will result in the support for the 104 artists (this is the structure of the data so that if a person listens to 5 different artists, that will be 5 rows in the data set). This will form an R matrix.

music_data2<-dcast(music_data,V1~V3,value.var='V4') music_data2<-music_data2[,lapply(.SD,function(x){as.numeric(x>0&!is.na(x))}),.SDcols=2:ncol(music_data2)] music_data2<-as.matrix(music_data2)

You will next use arules and apriori to develop the mining association rules for these artists, which will enable you to show the support that listening to one artist gives to other artists; in other words, providing lift to an associated artist. The arules procedure will filter the data to determine if listening to one artist results in listening to other artists.

music_transactions<-transactions(music_data2) rules_result<-apriori(music_transactions,parameter=list(supp=0.6,conf=0.6))

## Apriori ## ## Parameter specification: ## confidence minval smax arem aval originalSupport maxtime support minlen ## 0.6 0.1 1 none FALSE TRUE 5 0.6 1 ## maxlen targetext ## 10rules TRUE ## ## Algorithmic control: ## filter tree heap memopt load sort verbose ## 0.1 TRUE TRUE FALSE TRUE 2 TRUE ## ## Absolute minimum support count: 600 ## ## set item appearances ...[0 item(s)] done [0.00s]. ## set transactions ...[104 item(s), 1000 transaction(s)] done [0.00s]. ## sorting and recoding items ... [6 item(s)] done [0.00s]. ## creating transaction tree ... done [0.00s]. ## checking subsets of size 1 2 done [0.00s]. ## writing ... [16 rule(s)] done [0.00s]. ## creating S4 object ... done [0.00s].

rules_result<-DATAFRAME(rules_result) kable(rules_result)

LHS RHS support confidence coverage lift count
{} {the beatles} 0.684 0.6840000 1.000 1.0000000 684
{} {coldplay} 0.686 0.6860000 1.000 1.0000000 686
{} {red hot chili peppers} 0.699 0.6990000 1.000 1.0000000 699
{} {nirvana} 0.702 0.7020000 1.000 1.0000000 702
{} {muse} 0.733 0.7330000 1.000 1.0000000 733
{} {radiohead} 0.879 0.8790000 1.000 1.0000000 879
{the beatles} {radiohead} 0.607 0.8874269 0.684 1.0095869 607
{radiohead} {the beatles} 0.607 0.6905575 0.879 1.0095869 607
{coldplay} {radiohead} 0.616 0.8979592 0.686 1.0215690 616
{radiohead} {coldplay} 0.616 0.7007964 0.879 1.0215690 616
{red hot chili peppers} {radiohead} 0.606 0.8669528 0.699 0.9862944 606
{radiohead} {red hot chili peppers} 0.606 0.6894198 0.879 0.9862944 606
{nirvana} {radiohead} 0.616 0.8774929 0.702 0.9982854 616
{radiohead} {nirvana} 0.616 0.7007964 0.879 0.9982854 616
{muse} {radiohead} 0.650 0.8867667 0.733 1.0088358 650
{radiohead} {muse} 0.650 0.7394767 0.879 1.0088358 650

The deliverable should accomplish the following:

The results should be provided with a detailed explanation of the instructions on how you produced the results.

Discuss how the data were structured so that if one person listens to 5 different artists, that will be 5 rows in the data set.

Describe and show how to use arules for the mining association rules. Describe how the data became an R matrix. Show how you constructed the rule that shows that an artist provided lift to other artists.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!