El Market Basket Analysis es una técnica en el
ámbito de análisis y minería de datos en el campo del comercio. Su
objetivo principal es descubrir patrones de asociación entre productos
que suelen ser comprados juntos por los clientes.
Las tres metricas principales para evaluar las reglas de asociación
son:
* Confidence (Confianza): Probabilidad de comprar B sabiendo
que se compro A. Ej. Pan -> Mantequilla 0.8. De cada 100 clientes que
compraron pan, 80 compraron mantequilla también.
* Lift (Elevación): Cuánto más probable es comprar B cuando se
compra A en comparación de la probabilidad de comprar B sin saber si se
compro A. Ej.Lift > 1 Compra A impulsa B. Lift = 1 No tienen relación
de compra. Lift < 1 A reduce la compra de B.
* Support (Soporte): Popularidad del producto dentro de las
transacciones. Ej. Pan y Mantequilla 0.05 El 5% de todas las
transacciones compraron estos dos productos juntos.
# Contexto Una cadena de tiendas de
conveniencia tiene 5 tiendas ubicadas en distintas ciudades de México.
La base de datos “abarrotes” contiene un mes de transacciones, pero
presenta errores de calidad que impiden realizar analisis confiables. El
objetivo es limpiar la base de datos de forma estratégica y
posteriormente aplicar MBA para descubrir patrones de compra y diseñaar
promociones que aumenten las ventas.
#install.packages("tidyverse") # Paquete global para manipulación de datos
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
#install.packages("janitor") # Examinar y limpiar bases de datos sucias
library(janitor)
##
## Adjuntando el paquete: 'janitor'
##
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
#install.packages("Matriz") # Para trabajar con matrices
library(Matrix)
##
## Adjuntando el paquete: 'Matrix'
##
## The following objects are masked from 'package:tidyr':
##
## expand, pack, unpack
#install.packages("arules") # Genera reglas de asociación
library(arules)
##
## Adjuntando el paquete: 'arules'
##
## The following object is masked from 'package:dplyr':
##
## recode
##
## The following objects are masked from 'package:base':
##
## abbreviate, write
#install.packages("arulesViz") # Visualizar reglas de asociación
library(arulesViz)
#install.packages("plyr")
library(plyr)
## ------------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## ------------------------------------------------------------------------------
##
## Adjuntando el paquete: 'plyr'
##
## The following objects are masked from 'package:dplyr':
##
## arrange, count, desc, mutate, rename, summarise, summarize
##
## The following object is masked from 'package:purrr':
##
## compact
df <- read.csv("C:/Users/dulce/OneDrive/Escritorio/IA Empresarial/abarrotes.csv")
summary(df)
## ClaveTienda DescGiro Codigo.Barras PLU
## Length :200625 Length :200625 Min. :8.347e+05 Min. : 1.000
## N.unique : 5 N.unique : 3 1st Qu.:7.501e+12 1st Qu.: 1.000
## N.blank : 0 N.blank : 0 Median :7.501e+12 Median : 1.000
## Min.nchar: 5 Min.nchar: 8 Mean :5.950e+12 Mean : 2.112
## Max.nchar: 5 Max.nchar: 10 3rd Qu.:7.501e+12 3rd Qu.: 1.000
## Max. :1.750e+13 Max. :30.000
## NAs :199188
## Fecha Hora Marca Fabricante
## Length :200625 Length :200625 Length :200625 Length :200625
## N.unique : 195 N.unique : 52145 N.unique : 540 N.unique : 241
## N.blank : 0 N.blank : 0 N.blank : 0 N.blank : 0
## Min.nchar: 10 Min.nchar: 8 Min.nchar: 3 Min.nchar: 3
## Max.nchar: 10 Max.nchar: 8 Max.nchar: 30 Max.nchar: 40
##
##
## Producto Precio Ult.Costo Unidades
## Length :200625 Min. :-147.00 Min. : 0.38 Min. : 0.200
## N.unique : 3406 1st Qu.: 11.00 1st Qu.: 8.46 1st Qu.: 1.000
## N.blank : 0 Median : 16.00 Median : 12.31 Median : 1.000
## Min.nchar: 4 Mean : 19.42 Mean : 15.31 Mean : 1.262
## Max.nchar: 40 3rd Qu.: 25.00 3rd Qu.: 19.23 3rd Qu.: 1.000
## Max. :1000.00 Max. :769.23 Max. :96.000
##
## F.Ticket NombreDepartamento NombreFamilia NombreCategoria
## Min. : 1 Length :200625 Length :200625 Length :200625
## 1st Qu.: 33964 N.unique : 9 N.unique : 51 N.unique : 174
## Median :105993 N.blank : 0 N.blank : 0 N.blank : 0
## Mean :193990 Min.nchar: 6 Min.nchar: 3 Min.nchar: 2
## 3rd Qu.:383005 Max.nchar: 20 Max.nchar: 25 Max.nchar: 37
## Max. :450040
##
## Estado Mts.2 Tipo.ubicación Giro
## Length :200625 Min. :47.0 Length :200625 Length :200625
## N.unique : 5 1st Qu.:53.0 N.unique : 3 N.unique : 2
## N.blank : 0 Median :60.0 N.blank : 0 N.blank : 0
## Min.nchar: 7 Mean :56.6 Min.nchar: 7 Min.nchar: 9
## Max.nchar: 12 3rd Qu.:60.0 Max.nchar: 12 Max.nchar: 10
## Max. :62.0
##
## Hora.inicio Hora.cierre
## Length :200625 Length :200625
## N.unique : 3 N.unique : 3
## N.blank : 0 N.blank : 0
## Min.nchar: 5 Min.nchar: 5
## Max.nchar: 5 Max.nchar: 5
##
##
str(df)
## 'data.frame': 200625 obs. of 22 variables:
## $ ClaveTienda : chr "MX001" "MX001" "MX001" "MX001" ...
## $ DescGiro : chr "Abarrotes" "Abarrotes" "Abarrotes" "Abarrotes" ...
## $ Codigo.Barras : num 7.5e+12 7.5e+12 7.5e+12 7.5e+12 7.5e+12 ...
## $ PLU : int NA NA NA NA NA NA NA NA NA NA ...
## $ Fecha : chr "19/06/2020" "19/06/2020" "19/06/2020" "19/06/2020" ...
## $ Hora : chr "08:16:21" "08:23:33" "08:24:33" "08:24:33" ...
## $ Marca : chr "NUTRI LECHE" "DAN UP" "BIMBO" "PEPSI" ...
## $ Fabricante : chr "MEXILAC" "DANONE DE MEXICO" "GRUPO BIMBO" "PEPSI-COLA MEXICANA" ...
## $ Producto : chr "Nutri Leche 1 Litro" "DANUP STRAWBERRY P/BEBER 350GR NAL" "Rebanadas Bimbo 2Pz" "Pepsi N.R. 400Ml" ...
## $ Precio : num 16 14 5 8 19.5 16 14 5 8 19.5 ...
## $ Ult.Costo : num 12.3 14 5 8 15 ...
## $ Unidades : num 1 1 1 1 1 1 1 1 1 1 ...
## $ F.Ticket : int 1 2 3 3 4 1 2 3 3 4 ...
## $ NombreDepartamento: chr "Abarrotes" "Abarrotes" "Abarrotes" "Abarrotes" ...
## $ NombreFamilia : chr "Lacteos y Refrigerados" "Lacteos y Refrigerados" "Pan y Tortilla" "Bebidas" ...
## $ NombreCategoria : chr "Leche" "Yogurt" "Pan Dulce Empaquetado" "Refrescos Plástico (N.R.)" ...
## $ Estado : chr "Nuevo León" "Nuevo León" "Nuevo León" "Nuevo León" ...
## $ Mts.2 : int 60 60 60 60 60 60 60 60 60 60 ...
## $ Tipo.ubicación : chr "Esquina" "Esquina" "Esquina" "Esquina" ...
## $ Giro : chr "Abarrotes" "Abarrotes" "Abarrotes" "Abarrotes" ...
## $ Hora.inicio : chr "08:00" "08:00" "08:00" "08:00" ...
## $ Hora.cierre : chr "22:00" "22:00" "22:00" "22:00" ...
# count(df, ClaveTienda, sort=TRUE)
# count(df, DescGiro, sort=TRUE)
# count(df, Fecha, sort=TRUE)
# count(df, Hora, sort=TRUE)
# count(df, Marca, sort=TRUE)
# count(df, Fabricante, sort=TRUE)
# count(df, Producto, sort=TRUE)
# count(df, NombreDepartamento, sort=TRUE)
# count(df, NombreFamilia, sort=TRUE)
# count(df, NombreCategoria, sort=TRUE)
# count(df, Estado, sort=TRUE)
# count(df, Tipo.ubicacion, sort=TRUE)
# count(df, Giro, sort=TRUE)
# count(df, Hora.inicio, sort=TRUE)
# count(df, Hora.cierre, sort=TRUE)
head(df)
## ClaveTienda DescGiro Codigo.Barras PLU Fecha Hora
## 1 MX001 Abarrotes 7.501021e+12 NA 19/06/2020 08:16:21
## 2 MX001 Abarrotes 7.501032e+12 NA 19/06/2020 08:23:33
## 3 MX001 Abarrotes 7.501000e+12 NA 19/06/2020 08:24:33
## 4 MX001 Abarrotes 7.501031e+12 NA 19/06/2020 08:24:33
## 5 MX001 Abarrotes 7.501026e+12 NA 19/06/2020 08:26:28
## 6 MX001 Abarrotes 7.501021e+12 NA 19/06/2020 08:16:21
## Marca Fabricante
## 1 NUTRI LECHE MEXILAC
## 2 DAN UP DANONE DE MEXICO
## 3 BIMBO GRUPO BIMBO
## 4 PEPSI PEPSI-COLA MEXICANA
## 5 BLANCA NIEVES (DETERGENTE) FABRICA DE JABON LA CORONA
## 6 NUTRI LECHE MEXILAC
## Producto Precio Ult.Costo Unidades F.Ticket
## 1 Nutri Leche 1 Litro 16.0 12.31 1 1
## 2 DANUP STRAWBERRY P/BEBER 350GR NAL 14.0 14.00 1 2
## 3 Rebanadas Bimbo 2Pz 5.0 5.00 1 3
## 4 Pepsi N.R. 400Ml 8.0 8.00 1 3
## 5 Detergente Blanca Nieves 500G 19.5 15.00 1 4
## 6 Nutri Leche 1 Litro 16.0 12.31 1 1
## NombreDepartamento NombreFamilia NombreCategoria
## 1 Abarrotes Lacteos y Refrigerados Leche
## 2 Abarrotes Lacteos y Refrigerados Yogurt
## 3 Abarrotes Pan y Tortilla Pan Dulce Empaquetado
## 4 Abarrotes Bebidas Refrescos Plástico (N.R.)
## 5 Abarrotes Limpieza del Hogar Lavandería
## 6 Abarrotes Lacteos y Refrigerados Leche
## Estado Mts.2 Tipo.ubicación Giro Hora.inicio Hora.cierre
## 1 Nuevo León 60 Esquina Abarrotes 08:00 22:00
## 2 Nuevo León 60 Esquina Abarrotes 08:00 22:00
## 3 Nuevo León 60 Esquina Abarrotes 08:00 22:00
## 4 Nuevo León 60 Esquina Abarrotes 08:00 22:00
## 5 Nuevo León 60 Esquina Abarrotes 08:00 22:00
## 6 Nuevo León 60 Esquina Abarrotes 08:00 22:00
tail(df,10)
## ClaveTienda DescGiro Codigo.Barras PLU Fecha Hora
## 200616 MX005 Depósito 7.62221e+12 NA 07/08/2020 19:30:13
## 200617 MX005 Depósito 7.62221e+12 NA 25/07/2020 18:42:24
## 200618 MX005 Depósito 7.62221e+12 NA 18/07/2020 22:45:58
## 200619 MX005 Depósito 7.62221e+12 NA 12/07/2020 00:36:34
## 200620 MX005 Depósito 7.62221e+12 NA 12/07/2020 01:08:25
## 200621 MX005 Depósito 7.62221e+12 NA 23/10/2020 22:17:37
## 200622 MX005 Depósito 7.62221e+12 NA 10/10/2020 20:30:20
## 200623 MX005 Depósito 7.62221e+12 NA 10/10/2020 22:40:43
## 200624 MX005 Depósito 7.62221e+12 NA 27/06/2020 22:30:19
## 200625 MX005 Depósito 7.62221e+12 NA 26/06/2020 23:43:34
## Marca Fabricante Producto Precio
## 200616 TRIDENT XTRA CARE CADBURY ADAMS Trident Xtracare Freshmint 16.32G 9
## 200617 TRIDENT XTRA CARE CADBURY ADAMS Trident Xtracare Freshmint 16.32G 9
## 200618 TRIDENT XTRA CARE CADBURY ADAMS Trident Xtracare Freshmint 16.32G 9
## 200619 TRIDENT XTRA CARE CADBURY ADAMS Trident Xtracare Freshmint 16.32G 9
## 200620 TRIDENT XTRA CARE CADBURY ADAMS Trident Xtracare Freshmint 16.32G 9
## 200621 TRIDENT XTRA CARE CADBURY ADAMS Trident Xtracare Freshmint 16.32G 9
## 200622 TRIDENT XTRA CARE CADBURY ADAMS Trident Xtracare Freshmint 16.32G 9
## 200623 TRIDENT XTRA CARE CADBURY ADAMS Trident Xtracare Freshmint 16.32G 9
## 200624 TRIDENT XTRA CARE CADBURY ADAMS Trident Xtracare Freshmint 16.32G 9
## 200625 TRIDENT XTRA CARE CADBURY ADAMS Trident Xtracare Freshmint 16.32G 9
## Ult.Costo Unidades F.Ticket NombreDepartamento NombreFamilia
## 200616 6.92 1 106411 Abarrotes Dulcería
## 200617 6.92 1 104693 Abarrotes Dulcería
## 200618 6.92 1 103856 Abarrotes Dulcería
## 200619 6.92 1 103087 Abarrotes Dulcería
## 200620 6.92 1 103100 Abarrotes Dulcería
## 200621 6.92 1 116598 Abarrotes Dulcería
## 200622 6.92 1 114886 Abarrotes Dulcería
## 200623 6.92 1 114955 Abarrotes Dulcería
## 200624 6.92 1 101121 Abarrotes Dulcería
## 200625 6.92 1 100879 Abarrotes Dulcería
## NombreCategoria Estado Mts.2 Tipo.ubicación Giro Hora.inicio
## 200616 Gomas de Mazcar Quintana Roo 58 Esquina Mini súper 08:00
## 200617 Gomas de Mazcar Quintana Roo 58 Esquina Mini súper 08:00
## 200618 Gomas de Mazcar Quintana Roo 58 Esquina Mini súper 08:00
## 200619 Gomas de Mazcar Quintana Roo 58 Esquina Mini súper 08:00
## 200620 Gomas de Mazcar Quintana Roo 58 Esquina Mini súper 08:00
## 200621 Gomas de Mazcar Quintana Roo 58 Esquina Mini súper 08:00
## 200622 Gomas de Mazcar Quintana Roo 58 Esquina Mini súper 08:00
## 200623 Gomas de Mazcar Quintana Roo 58 Esquina Mini súper 08:00
## 200624 Gomas de Mazcar Quintana Roo 58 Esquina Mini súper 08:00
## 200625 Gomas de Mazcar Quintana Roo 58 Esquina Mini súper 08:00
## Hora.cierre
## 200616 21:00
## 200617 21:00
## 200618 21:00
## 200619 21:00
## 200620 21:00
## 200621 21:00
## 200622 21:00
## 200623 21:00
## 200624 21:00
## 200625 21:00
# Tabla de Tienda y Departamento
tabyl(df, ClaveTienda, NombreDepartamento)
## ClaveTienda Abarrotes Bebes e Infantiles Carnes Farmacia Ferretería Mercería
## MX001 95415 515 1 147 245 28
## MX002 6590 21 0 4 10 0
## MX003 4026 15 0 2 8 0
## MX004 82234 932 0 102 114 16
## MX005 10014 0 0 0 0 0
## Papelería Productos a Eliminar Vinos y Licores
## 35 3 80
## 0 0 4
## 0 0 0
## 32 5 20
## 7 0 0
# Tabla de Estado y Hora de Inicio
tabyl(df, Estado, Hora.inicio)
## Estado 07:00 08:00 09:00
## Chiapas 4051 0 0
## Jalisco 0 0 6629
## Nuevo León 0 96469 0
## Quintana Roo 0 10021 0
## Sinaloa 83455 0 0
# Elimar columnas
df <- subset(df, select =-(PLU))
# Eliminar renglones
df <- df[df$Precio>0, ]
df <- distinct(df)
df$Unidades <- ceiling(df$Unidades)
df$Fecha <- as.Date(df$Fecha, format= "%d/%m/%Y")
#Borrar todos los NAs
# df <- na.omit(df)
#Remplazar NAs con CEROS
# df[is.na(df)] <- 0
#Remplazar con promedios
# df$altura[is.na(df$altura)] <- mean(df$altura, na.rn=TRUE)
boxplot(df$Precio, horizontal = TRUE)
#Ordenar de menor a mayor por ticket
df <- df[order(df$F.Ticket),]
#Generar Basket
basket <- ddply(df, c("F.Ticket"), function(df)paste(df$Marca, collapse=","))
#Eliminar número de ticket
basket$F.Ticket <- NULL
#Cambiar el título de la columna V1 por Marca
colnames(basket) <- c("Marca")
#Exportar basket
write.csv(basket, "basket.csv", quote = FALSE, row.names = FALSE)
tr <- read.transactions("C:/Users/dulce/OneDrive/Escritorio/IA Empresarial/basket.csv")
## Warning in asMethod(object): removing duplicated items in transactions
reglas.asociacion <- apriori(tr, parameter=list(supp=0.001, conf=0.2, maxlen=10))
## Apriori
##
## Parameter specification:
## confidence minval smax arem aval originalSupport maxtime support minlen
## 0.2 0.1 1 none FALSE TRUE 5 0.001 1
## maxlen target ext
## 10 rules TRUE
##
## Algorithmic control:
## filter tree heap memopt load sort verbose
## 0.1 TRUE TRUE FALSE TRUE 2 TRUE
##
## Absolute minimum support count: 115
##
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[27292 item(s), 115031 transaction(s)] done [0.11s].
## sorting and recoding items ... [191 item(s)] done [0.00s].
## creating transaction tree ... done [0.02s].
## checking subsets of size 1 2 3 4 done [0.00s].
## writing ... [139 rule(s)] done [0.00s].
## creating S4 object ... done [0.01s].
# summary(reglas.asociacion)
# inspect(reglas.asociacion)
reglas.asociacion <- sort(reglas.asociacion, by="confidence", decreasing= TRUE)
summary(reglas.asociacion)
## set of 139 rules
##
## rule length distribution (lhs + rhs):sizes
## 2 3 4
## 103 32 4
##
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.000 2.000 2.000 2.288 3.000 4.000
##
## summary of quality measures:
## support confidence coverage lift
## Min. :0.001008 Min. :0.2036 Min. :0.001008 Min. : 3.775
## 1st Qu.:0.001447 1st Qu.:0.5239 1st Qu.:0.001986 1st Qu.: 36.104
## Median :0.001947 Median :0.6967 Median :0.002851 Median :117.230
## Mean :0.003772 Mean :0.7050 Mean :0.006223 Mean :173.456
## 3rd Qu.:0.003925 3rd Qu.:0.9634 3rd Qu.:0.005894 3rd Qu.:286.860
## Max. :0.080526 Max. :1.0000 Max. :0.119124 Max. :827.561
## count
## Min. : 116.0
## 1st Qu.: 166.5
## Median : 224.0
## Mean : 433.9
## 3rd Qu.: 451.5
## Max. :9263.0
##
## mining info:
## data ntransactions support confidence
## tr 115031 0.001 0.2
## call
## apriori(data = tr, parameter = list(supp = 0.001, conf = 0.2, maxlen = 10))
inspect(reglas.asociacion)
## lhs rhs support confidence
## [1] {%} => {100} 0.001008424 1.0000000
## [2] {ZONA} => {DEL} 0.001112744 1.0000000
## [3] {DOS} => {EQUIS} 0.001182290 1.0000000
## [4] {FIOR} => {DI} 0.001086664 1.0000000
## [5] {DART} => {(PLAST} 0.001182290 1.0000000
## [6] {MODELO)} => {(CERV.} 0.001356156 1.0000000
## [7] {CREMAX} => {DE} 0.001373543 1.0000000
## [8] {FRUTO)} => {(DEL} 0.001947301 1.0000000
## [9] {LAGER} => {EQUIS} 0.002060314 1.0000000
## [10] {BENSON} => {&} 0.002121167 1.0000000
## [11] {SABOR} => {DEL} 0.002025541 1.0000000
## [12] {HEDGES} => {&} 0.002190714 1.0000000
## [13] {BARRILITOS} => {(DEL} 0.002486286 1.0000000
## [14] {(DETERGENTE)} => {NIEVES} 0.002851405 1.0000000
## [15] {ZERO} => {COLA} 0.003512097 1.0000000
## [16] {ORO} => {GALLO} 0.004859560 1.0000000
## [17] {ORO} => {DE} 0.004859560 1.0000000
## [18] {GALLO} => {DE} 0.005894063 1.0000000
## [19] {SABOR, ZONA} => {DEL} 0.001077970 1.0000000
## [20] {BARRILITOS, FRUTO)} => {(DEL} 0.001495249 1.0000000
## [21] {BENSON, HEDGES} => {&} 0.001477862 1.0000000
## [22] {(DETERGENTE), BLANCA} => {NIEVES} 0.001947301 1.0000000
## [23] {EL, ORO} => {GALLO} 0.001851675 1.0000000
## [24] {EL, ORO} => {DE} 0.001851675 1.0000000
## [25] {EL, GALLO} => {DE} 0.002121167 1.0000000
## [26] {DE, EL} => {GALLO} 0.002121167 1.0000000
## [27] {COCA, ZERO} => {COLA} 0.001825595 1.0000000
## [28] {GALLO, ORO} => {DE} 0.004859560 1.0000000
## [29] {DE, ORO} => {GALLO} 0.004859560 1.0000000
## [30] {EL, GALLO, ORO} => {DE} 0.001851675 1.0000000
## [31] {DE, EL, ORO} => {GALLO} 0.001851675 1.0000000
## [32] {LIGHT,COCA} => {COLA} 0.001417009 0.9878788
## [33] {COCA, LIGHT} => {COLA} 0.003842442 0.9735683
## [34] {ZONA} => {SABOR} 0.001077970 0.9687500
## [35] {DEL, ZONA} => {SABOR} 0.001077970 0.9687500
## [36] {MEXICO} => {VELADORA} 0.004555294 0.9579525
## [37] {ARDILLA,LA, LA} => {ARDILLA} 0.001217063 0.9210526
## [38] {CHICO,COCA} => {TOPO} 0.001321383 0.9101796
## [39] {ABSOR} => {SEC} 0.001138823 0.9097222
## [40] {ARDILLA,LA} => {ARDILLA} 0.002321113 0.8782895
## [41] {EL, GALLO} => {ORO} 0.001851675 0.8729508
## [42] {DE, EL} => {ORO} 0.001851675 0.8729508
## [43] {DE, EL, GALLO} => {ORO} 0.001851675 0.8729508
## [44] {PALL} => {MALL} 0.005772357 0.8668407
## [45] {CHICO} => {TOPO} 0.004746547 0.8425926
## [46] {100} => {%} 0.001008424 0.8345324
## [47] {FINA} => {LA} 0.002225487 0.8311688
## [48] {COCA, COLA,COCA} => {COLA} 0.003903296 0.8253676
## [49] {GALLO} => {ORO} 0.004859560 0.8244838
## [50] {DE, GALLO} => {ORO} 0.004859560 0.8244838
## [51] {MARIA} => {DOÑA} 0.001451783 0.8186275
## [52] {COLA,COCA} => {COLA} 0.005155132 0.8090041
## [53] {CARTA} => {BLANCA} 0.002234180 0.8081761
## [54] {(CERV.} => {MODELO)} 0.001356156 0.8041237
## [55] {EQUIS} => {LAGER} 0.002060314 0.8033898
## [56] {(DEL} => {BARRILITOS} 0.002486286 0.7750678
## [57] {FRUTO)} => {BARRILITOS} 0.001495249 0.7678571
## [58] {(DEL, FRUTO)} => {BARRILITOS} 0.001495249 0.7678571
## [59] {COLA,TECATE} => {COCA} 0.003590337 0.7676580
## [60] {PEPSI,COCA} => {COLA} 0.002025541 0.7614379
## [61] {COLA, COLA,COCA} => {COCA} 0.003903296 0.7571669
## [62] {EL} => {GALLO} 0.002121167 0.7439024
## [63] {EL} => {DE} 0.002121167 0.7439024
## [64] {COLA,COCA} => {COCA} 0.004729160 0.7421555
## [65] {COLA,JOYA} => {COCA} 0.001034504 0.7212121
## [66] {(PLAST} => {DART} 0.001182290 0.7195767
## [67] {BIMBO,COCA} => {COLA} 0.001634342 0.7148289
## [68] {COCA} => {COLA} 0.080526119 0.7131419
## [69] {FORTILECHE} => {LECHE} 0.001599569 0.6969697
## [70] {BENSON} => {HEDGES} 0.001477862 0.6967213
## [71] {&, BENSON} => {HEDGES} 0.001477862 0.6967213
## [72] {SEC} => {ABSOR} 0.001138823 0.6894737
## [73] {LIGHT} => {COLA} 0.006380889 0.6892019
## [74] {(GAMESA)} => {SALADITAS} 0.004155402 0.6848138
## [75] {(DETERGENTE)} => {BLANCA} 0.001947301 0.6829268
## [76] {(DETERGENTE), NIEVES} => {BLANCA} 0.001947301 0.6829268
## [77] {MANZANITA} => {SOL} 0.002347193 0.6766917
## [78] {COLA} => {COCA} 0.080526119 0.6759834
## [79] {HEDGES} => {BENSON} 0.001477862 0.6746032
## [80] {&, HEDGES} => {BENSON} 0.001477862 0.6746032
## [81] {COLA,PEPSI} => {COCA} 0.001251836 0.6666667
## [82] {SABORES} => {PEÑAFIEL} 0.001025810 0.6519337
## [83] {EL} => {ORO} 0.001851675 0.6493902
## [84] {MALL} => {PALL} 0.005772357 0.6378482
## [85] {ROSA} => {TIA} 0.001051890 0.6368421
## [86] {&} => {HEDGES} 0.002190714 0.6284289
## [87] {&} => {BENSON} 0.002121167 0.6084788
## [88] {(DEL} => {FRUTO)} 0.001947301 0.6070461
## [89] {SEVEN} => {UP} 0.001443089 0.6036364
## [90] {COLA, LIGHT} => {COCA} 0.003842442 0.6021798
## [91] {BARRILITOS} => {FRUTO)} 0.001495249 0.6013986
## [92] {(DEL, BARRILITOS} => {FRUTO)} 0.001495249 0.6013986
## [93] {NIEVES} => {BLANCA} 0.004346654 0.6002401
## [94] {LECHE} => {NUTRI} 0.009536560 0.5907377
## [95] {DE} => {GALLO} 0.005894063 0.5716695
## [96] {DI} => {FIOR} 0.001086664 0.5681818
## [97] {COSTEÑA} => {LA} 0.005798437 0.5666950
## [98] {BLUE} => {HOUSE} 0.001434396 0.5536913
## [99] {ARDILLA} => {LA} 0.007215446 0.5507631
## [100] {SIERRA} => {LA} 0.001269223 0.5427509
## [101] {NUTRI} => {LECHE} 0.009536560 0.5322659
## [102] {SABOR} => {ZONA} 0.001077970 0.5321888
## [103] {DEL, SABOR} => {ZONA} 0.001077970 0.5321888
## [104] {ARDILLA, ARDILLA,LA} => {LA} 0.001217063 0.5243446
## [105] {MONTE} => {DEL} 0.003981535 0.5234286
## [106] {ZERO} => {COCA} 0.001825595 0.5198020
## [107] {COLA, ZERO} => {COCA} 0.001825595 0.5198020
## [108] {FRUT} => {VALLE} 0.004511827 0.5128458
## [109] {NUESTRA} => {LA} 0.002312420 0.5047438
## [110] {BLANCA} => {NIEVES} 0.004346654 0.5025126
## [111] {ARDILLA,LA} => {LA} 0.001321383 0.5000000
## [112] {HOUSE} => {BLUE} 0.001434396 0.4768786
## [113] {FUERTE} => {DEL} 0.004894333 0.4751055
## [114] {DE} => {ORO} 0.004859560 0.4713322
## [115] {VELADORA} => {MEXICO} 0.004555294 0.4641275
## [116] {PEÑAFIEL} => {SABORES} 0.001025810 0.4627451
## [117] {EQUIS} => {DOS} 0.001182290 0.4610169
## [118] {BLANCA, NIEVES} => {(DETERGENTE)} 0.001947301 0.4480000
## [119] {LIGHT} => {COCA} 0.003946762 0.4262911
## [120] {TIA} => {ROSA} 0.001051890 0.4201389
## [121] {DOÑA} => {MARIA} 0.001451783 0.4195980
## [122] {UP} => {SEVEN} 0.001443089 0.4160401
## [123] {SOL} => {MANZANITA} 0.002347193 0.4066265
## [124] {NIEVES} => {(DETERGENTE)} 0.002851405 0.3937575
## [125] {TOPO} => {CHICO} 0.004746547 0.3875089
## [126] {ORO} => {EL} 0.001851675 0.3810376
## [127] {GALLO, ORO} => {EL} 0.001851675 0.3810376
## [128] {DE, ORO} => {EL} 0.001851675 0.3810376
## [129] {DE, GALLO, ORO} => {EL} 0.001851675 0.3810376
## [130] {GALLO} => {EL} 0.002121167 0.3598820
## [131] {DE, GALLO} => {EL} 0.002121167 0.3598820
## [132] {SALADITAS} => {(GAMESA)} 0.004155402 0.3504399
## [133] {VALLE} => {FRUT} 0.004511827 0.3176255
## [134] {BLANCA} => {CARTA} 0.002234180 0.2582915
## [135] {BLANCA} => {(DETERGENTE)} 0.001947301 0.2251256
## [136] {VALLE} => {DEL} 0.002929645 0.2062424
## [137] {DE} => {EL} 0.002121167 0.2057336
## [138] {DEL} => {FUERTE} 0.004894333 0.2056997
## [139] {LA} => {ARDILLA} 0.007215446 0.2035811
## coverage lift count
## [1] 0.001008424 827.561151 116
## [2] 0.001112744 42.028133 128
## [3] 0.001182290 389.935593 136
## [4] 0.001086664 522.868182 125
## [5] 0.001182290 608.629630 136
## [6] 0.001356156 592.943299 156
## [7] 0.001373543 96.990725 158
## [8] 0.001947301 311.737127 224
## [9] 0.002060314 389.935593 237
## [10] 0.002121167 286.860349 244
## [11] 0.002025541 42.028133 233
## [12] 0.002190714 286.860349 252
## [13] 0.002486286 311.737127 286
## [14] 0.002851405 138.092437 328
## [15] 0.003512097 8.394585 404
## [16] 0.004859560 169.662242 559
## [17] 0.004859560 96.990725 559
## [18] 0.005894063 96.990725 678
## [19] 0.001077970 42.028133 124
## [20] 0.001495249 311.737127 172
## [21] 0.001477862 286.860349 170
## [22] 0.001947301 138.092437 224
## [23] 0.001851675 169.662242 213
## [24] 0.001851675 96.990725 213
## [25] 0.002121167 96.990725 244
## [26] 0.002121167 169.662242 244
## [27] 0.001825595 8.394585 210
## [28] 0.004859560 96.990725 559
## [29] 0.004859560 169.662242 559
## [30] 0.001851675 96.990725 213
## [31] 0.001851675 169.662242 213
## [32] 0.001434396 8.292833 163
## [33] 0.003946762 8.172702 442
## [34] 0.001112744 478.267302 124
## [35] 0.001112744 478.267302 124
## [36] 0.004755240 97.603393 524
## [37] 0.001321383 70.304980 140
## [38] 0.001451783 74.307221 152
## [39] 0.001251836 550.769773 131
## [40] 0.002642766 67.040820 267
## [41] 0.002121167 179.635788 213
## [42] 0.002121167 179.635788 213
## [43] 0.002121167 179.635788 213
## [44] 0.006659075 95.786317 664
## [45] 0.005633264 68.789403 546
## [46] 0.001208370 827.561151 116
## [47] 0.002677539 23.451112 256
## [48] 0.004729160 6.928619 449
## [49] 0.005894063 169.662242 559
## [50] 0.005894063 169.662242 559
## [51] 0.001773435 236.601845 167
## [52] 0.006372195 6.791254 593
## [53] 0.002764472 93.432467 257
## [54] 0.001686502 592.943299 156
## [55] 0.002564526 389.935593 237
## [56] 0.003207831 311.737127 286
## [57] 0.001947301 308.836976 172
## [58] 0.001947301 308.836976 172
## [59] 0.004677000 6.798404 413
## [60] 0.002660152 6.391955 233
## [61] 0.005155132 6.705495 449
## [62] 0.002851405 126.212156 244
## [63] 0.002851405 72.151637 244
## [64] 0.006372195 6.572553 544
## [65] 0.001434396 6.387078 119
## [66] 0.001643035 608.629630 136
## [67] 0.002286340 6.000692 188
## [68] 0.112917387 5.986530 9263
## [69] 0.002295034 43.173463 184
## [70] 0.002121167 318.033925 170
## [71] 0.002121167 318.033925 170
## [72] 0.001651729 550.769773 131
## [73] 0.009258374 5.785564 734
## [74] 0.006067930 57.752794 478
## [75] 0.002851405 78.952519 224
## [76] 0.002851405 78.952519 224
## [77] 0.003468630 117.229708 270
## [78] 0.119124410 5.986530 9263
## [79] 0.002190714 318.033925 170
## [80] 0.002190714 318.033925 170
## [81] 0.001877755 5.904021 144
## [82] 0.001573489 294.088571 118
## [83] 0.002851405 133.631501 213
## [84] 0.009049734 95.786317 664
## [85] 0.001651729 254.363140 121
## [86] 0.003486017 286.860349 252
## [87] 0.003486017 286.860349 244
## [88] 0.003207831 311.737127 224
## [89] 0.002390660 174.027305 166
## [90] 0.006380889 5.332924 442
## [91] 0.002486286 308.836976 172
## [92] 0.002486286 308.836976 172
## [93] 0.007241526 69.393184 500
## [94] 0.016143474 32.970963 1097
## [95] 0.010310264 96.990725 678
## [96] 0.001912528 522.868182 125
## [97] 0.010232024 15.989083 667
## [98] 0.002590606 184.079945 165
## [99] 0.013100816 15.539571 830
## [100] 0.002338500 15.313510 146
## [101] 0.017916909 32.970963 1097
## [102] 0.002025541 478.267302 124
## [103] 0.002025541 478.267302 124
## [104] 0.002321113 14.794182 140
## [105] 0.007606645 21.998726 458
## [106] 0.003512097 4.603383 210
## [107] 0.003512097 4.603383 210
## [108] 0.008797628 36.103532 519
## [109] 0.004581374 14.241155 266
## [110] 0.008649842 69.393184 500
## [111] 0.002642766 14.107309 152
## [112] 0.003007885 184.079945 165
## [113] 0.010301571 19.967797 563
## [114] 0.010310264 96.990725 559
## [115] 0.009814746 97.603393 524
## [116] 0.002216794 294.088571 118
## [117] 0.002564526 389.935593 136
## [118] 0.004346654 157.115512 224
## [119] 0.009258374 3.775247 454
## [120] 0.002503673 254.363140 121
## [121] 0.003459937 236.601845 167
## [122] 0.003468630 174.027305 166
## [123] 0.005772357 117.229708 270
## [124] 0.007241526 138.092437 328
## [125] 0.012248872 68.789403 546
## [126] 0.004859560 133.631501 213
## [127] 0.004859560 133.631501 213
## [128] 0.004859560 133.631501 213
## [129] 0.004859560 133.631501 213
## [130] 0.005894063 126.212156 244
## [131] 0.005894063 126.212156 244
## [132] 0.011857673 57.752794 478
## [133] 0.014204867 36.103532 519
## [134] 0.008649842 93.432467 257
## [135] 0.008649842 78.952519 224
## [136] 0.014204867 8.667981 337
## [137] 0.010310264 72.151637 244
## [138] 0.023793586 19.967797 563
## [139] 0.035442620 15.539571 830
top10reglas <- head(reglas.asociacion, n=10, by="confidence")
plot(top10reglas, method="graph", engine="htmlwidget")