Vous êtes sur la page 1sur 2

Las radios en línea suelen guardar un registro de todo lo que los usuarios escuchan.

Esta información es usada para


recomendar la música que posiblemente le guste al usuario y que soporte a las campañas de marketing que envían
propagandas de canciones que podrá comprar. Suponga que se tienen datos de los registros de usuarios de un sitio web de
música. Para cada usuario se tienen información demográfica así como de sus intereses. El objetivo de este análisis es
construir un sistema que recomiende música a los usuarios de la comunidad. Los datos se encuentran en el archivo lastfm.csv
de la carpeta compartida del curso.

> #Instalar paquetes


> install.packages("arules", dependencies = T)
> install.packages("arulesViz", dependencies = T)

> #Llamar librerías


> library(arules)
> library(arulesViz)

> #establecer escritorio


> #Leer Data Frame
> trans=read.transactions(file= file.choose(),format="single",sep=",",cols=c(1,2),rm.duplicates=TRUE)
distribution of transactions with duplicates:
1
2
> trans=read.transactions(file="lastfm.csv",format="single",sep=",",cols=c(1,2),rm.duplicates=TRUE)
distribution of transactions with duplicates:
1
2
> trans
transactions in sparse format with
15001 transactions (rows) and
1005 items (columns)

(a) Realice el análisis de asociación usando el algoritmo a priori considerando un


soporte mínimo de 0.01 y una confianza mínima de 0.5. Encuentre reglas de asociación
relevantes. Interprete sus resultados.
Apriori

Parameter specification:
confidence minval smax arem aval originalSupport support minlen maxlen target ext
0.5 0.1 1 none FALSE TRUE 0.01 1 10 rules FALSE

Algorithmic control:
filter tree heap memopt load sort verbose
0.1 TRUE TRUE FALSE TRUE 2 TRUE

Absolute minimum support count: 150

set item appearances ...[0 item(s)] done [0.00s].


set transactions ...[1005 item(s), 15001 transaction(s)] done [0.06s].
sorting and recoding items ... [651 item(s)] done [0.00s].
creating transaction tree ... done [0.02s].
checking subsets of size 1 2 3 4 done [0.05s].
writing ... [48 rule(s)] done [0.00s].
creating S4 object ... done [0.00s].
> rules <- apriori(trans, parameter = list(supp = 0.01, conf = 0.5, target = "rules"))

lhs rhs support confidence lift


1 {t.i.} => {kanye west} 0.01039931 0.5672727 8.855003
2 {the pussycat dolls} => {rihanna} 0.01039931 0.5777778 13.416787
3 {the fray} => {coldplay} 0.01126592 0.5168196 3.260223
4 {sonata arctica} => {nightwish} 0.01346577 0.5101010 8.236841
5 {judas priest} => {iron maiden} 0.01353243 0.5075000 8.563563
6 {the kinks} => {the beatles} 0.01359909 0.5298701 2.979229
7 {travis} => {coldplay} 0.01373242 0.5628415 3.550541
8 {the flaming lips} => {radiohead} 0.01306580 0.5297297 2.938785
9 {megadeth} => {metallica} 0.01626558 0.5281385 4.744075
10 {simon & garfunkel} => {the beatles} 0.01539897 0.5238095 2.945152
11 {broken social scene} => {radiohead} 0.01506566 0.5472155 3.035791
12 {blur} => {radiohead} 0.01753216 0.5228628 2.900690
13 {keane} => {coldplay} 0.02226518 0.6374046 4.020902
14 {snow patrol} => {coldplay} 0.02646490 0.5251323 3.312662
15 {beck} => {radiohead} 0.02926472 0.5092807 2.825340
16 {snow patrol,the killers} => {coldplay} 0.01039931 0.5954198 3.756053
17 {radiohead,snow patrol} => {coldplay} 0.01006600 0.6344538 4.002288
18 {death cab for cutie,the shins} => {radiohead} 0.01006600 0.5033333 2.792346
19 {the beatles,the shins} => {radiohead} 0.01066596 0.5673759 3.147635
20 {led zeppelin,the doors} => {pink floyd} 0.01066596 0.5970149 5.689848
21 {pink floyd,the doors} => {led zeppelin} 0.01066596 0.5387205 6.802480
22 {the beatles,the strokes} => {radiohead} 0.01046597 0.5607143 3.110679
23 {oasis,the killers} => {coldplay} 0.01113259 0.6626984 4.180462
24 {oasis,the beatles} => {coldplay} 0.01059929 0.5196078 3.277812
25 {oasis,radiohead} => {coldplay} 0.01273248 0.5876923 3.707305
26 {beck,the beatles} => {radiohead} 0.01299913 0.5909091 3.278191
27 {bob dylan,the rolling stones} => {the beatles} 0.01146590 0.5910653 3.323302
28 {led zeppelin,the rolling stones} => {the beatles} 0.01066596 0.5776173 3.247690
29 {radiohead,the rolling stones} => {the beatles} 0.01059929 0.5638298 3.170169
30 {coldplay,the smashing pumpkins} => {radiohead} 0.01093260 0.6283525 3.485916
31 {the beatles,the smashing pumpkins} => {radiohead} 0.01146590 0.6209386 3.444786
32 {radiohead,u2} => {coldplay} 0.01139924 0.5213415 3.288748
33 {coldplay,sigur rós} => {radiohead} 0.01206586 0.5801282 3.218381
34 {sigur rós,the beatles} => {radiohead} 0.01046597 0.6434426 3.569631
35 {bob dylan,pink floyd} => {the beatles} 0.01033264 0.6150794 3.458323
36 {bob dylan,radiohead} => {the beatles} 0.01386574 0.5730028 3.221744
37 {bloc party,the killers} => {coldplay} 0.01106593 0.5236593 3.303370
38 {david bowie,pink floyd} => {the beatles} 0.01006600 0.5741445 3.228164
39 {david bowie,radiohead} => {the beatles} 0.01393240 0.5225000 2.937790
40 {placebo,radiohead} => {muse} 0.01366576 0.5137845 4.504547
41 {led zeppelin,radiohead} => {the beatles} 0.01306580 0.5283019 2.970411
42 {death cab for cutie,the killers} => {coldplay} 0.01086594 0.5884477 3.712070
43 {death cab for cutie,the beatles} => {radiohead} 0.01246584 0.5013405 2.781290
44 {muse,the killers} => {coldplay} 0.01513232 0.5089686 3.210697
45 {red hot chili peppers,the killers} => {coldplay} 0.01086594 0.5093750 3.213261
46 {the beatles,the killers} => {coldplay} 0.01253250 0.5340909 3.369175
47 {radiohead,the killers} => {coldplay} 0.01506566 0.5243619 3.307802
48 {muse,the beatles} => {radiohead} 0.01379908 0.5073529 2.814646
> inspect(rules)

> plot(rules)

Nota:

Se encontraron 48 reglas para un soporte de 1% con una confianza de 50%, esto nos indica por eje
mplo en la regla 6 se puede interpretar de la siguiente manera: el 1.35% de las transacciones (f
ilas) contienen los Item de the kinks y the beatles, y de las transacciones que contiene a the k
inks el 5% contienen a the beatles.

El grafico del soporte vs la confianza de las 48 reglas se puede apreciar que presentan niveles
de soporte bajo versus una confianza relativa alta, esto muestra que uno o más artistas tienen b
aja probabilidad de repetirse en las transacciones.

(b) Considerando que se tenga un lift mayor a 5. ¿Qué recomendaría a un usuario que gu
sta de Judas Priest? ¿Y a los que gustan de the Pussycat Dolls?
lhs rhs support confidence lift
1 {t.i.} => {kanye west} 0.01039931 0.5672727 8.855003
2 {the pussycat dolls} => {rihanna} 0.01039931 0.5777778 13.416787
4 {sonata arctica} => {nightwish} 0.01346577 0.5101010 8.236841
5 {judas priest} => {iron maiden} 0.01353243 0.5075000 8.563563
20 {led zeppelin,the doors} => {pink floyd} 0.01066596 0.5970149 5.689848
21 {pink floyd,the doors} => {led zeppelin} 0.01066596 0.5387205 6.802480
> inspect(subset(rules, subset=lift > 5))

Nota:

Esta reglas tiene un lift muy alto, lo que signifique que bajo condiciones de independencia apar
ecen una cantidad de veces muy elevada a las esperadas, esto en base a un soporte teórico, por l
o que nos hace concluir a manera de hipótesis que existe una relación que hace que los artistas
se encuentren en el conjunto más veces de lo normal).

Vous aimerez peut-être aussi