Paso 1. Importar base de datos

#file.choose()

bd_limpia <- read.csv ( "C:\\Users\\danyc\\OneDrive - Instituto Tecnologico y de Estudios Superiores de Monterrey\\Desktop\\Excel y CSV\\abarrotes_ventas-2 .csv")

Notas previas: Modificación a Excel

Se pasó la base de datos limpia de abarrotes directamente y se hizo la continuación del trabajo, no se analizaron las bases de datos debido a que eso se hizo en el primer trabajo por lo tanto no hay errores que demostrar de la base si no del sistema, se dificultó el no tener la última versión en las computadoras debido a que no corre el programa de plot sin ello.

Herramienta “El Generador de Valor de Datos”

Paso 1. Definir el área del negocio que buscamos impactar o mejorar y su KPI

El área serían directamente marketing.

Los KPI´s a impactar son:

a. Ventas cruzadas b.Interacción del target

Paso 2. Seleccionar plantilla(-s) para crear valor a partir de los datos de los clientes.

Visión / Segmentación / Personalización / Contextualización

Paso 3. Generar ideas o conceptos específicos.

Creación de insights por medio de el analisis de datos.

Paso 4. Reunir los datos requeridos. Base de datos limpia con historial de los últimos años de ventas.

Paso 5. Plan de ejecución. a. Identificar los productos que más se compran en la tienda de abarrotes. b. Crear un Market Basket para determinar cuáles son los productos que más se venden juntos o tienen relación. c. Promocionar estos dos productos para atraer al cliente. d. Modificar los KPI´s en medida que se replanteen y se agreguen conforme el paso del tiempo y los resultados obtenidos.

Paso 2. Market base analysis

a. Instalar librerías

#install.packages("plyr")
#install.packages("arules")
#install.packages("arulesViz")
library(Matrix)
library(arules)
## 
## Attaching package: 'arules'
## The following objects are masked from 'package:base':
## 
##     abbreviate, write
library(arulesViz)
library(datasets)

b. Ordenar de menor a mayor los tickets

bd_limpia <-bd_limpia[order(bd_limpia$F.Ticket),]
head(bd_limpia)
##   vcClaveTienda  DescGiro Codigo.Barras PLU      Fecha           Hora
## 1         MX001 Abarrotes  7.501021e+12  NA 19/06/2020 08:16:21 a. m.
## 6         MX001 Abarrotes  7.501021e+12  NA 19/06/2020 08:16:21 a. m.
## 2         MX001 Abarrotes  7.501032e+12  NA 19/06/2020 08:23:33 a. m.
## 7         MX001 Abarrotes  7.501032e+12  NA 19/06/2020 08:23:33 a. m.
## 3         MX001 Abarrotes  7.501000e+12  NA 19/06/2020 08:24:33 a. m.
## 4         MX001 Abarrotes  7.501031e+12  NA 19/06/2020 08:24:33 a. m.
##         Marca          Fabricante                           Producto Precio
## 1 NUTRI LECHE             MEXILAC                Nutri Leche 1 Litro     16
## 6 NUTRI LECHE             MEXILAC                Nutri Leche 1 Litro     16
## 2      DAN UP    DANONE DE MEXICO DANUP STRAWBERRY P/BEBER 350GR NAL     14
## 7      DAN UP    DANONE DE MEXICO DANUP STRAWBERRY P/BEBER 350GR NAL     14
## 3       BIMBO         GRUPO BIMBO                Rebanadas Bimbo 2Pz      5
## 4       PEPSI PEPSI-COLA MEXICANA                   Pepsi N.R. 400Ml      8
##   Ult.Costo Unidades F.Ticket NombreDepartamento          NombreFamilia
## 1     12.31        1        1          Abarrotes Lacteos y Refrigerados
## 6     12.31        1        1          Abarrotes Lacteos y Refrigerados
## 2     14.00        1        2          Abarrotes Lacteos y Refrigerados
## 7     14.00        1        2          Abarrotes Lacteos y Refrigerados
## 3      5.00        1        3          Abarrotes         Pan y Tortilla
## 4      8.00        1        3          Abarrotes                Bebidas
##             NombreCategoria     Estado Mts.2 Tipo.ubicación      Giro
## 1                     Leche Nuevo León    60        Esquina Abarrotes
## 6                     Leche Nuevo León    60        Esquina Abarrotes
## 2                    Yogurt Nuevo León    60        Esquina Abarrotes
## 7                    Yogurt Nuevo León    60        Esquina Abarrotes
## 3     Pan Dulce Empaquetado Nuevo León    60        Esquina Abarrotes
## 4 Refrescos Plástico (N.R.) Nuevo León    60        Esquina Abarrotes
##   Hora.inicio Hora.cierre
## 1        8:00       22:00
## 6        8:00       22:00
## 2        8:00       22:00
## 7        8:00       22:00
## 3        8:00       22:00
## 4        8:00       22:00
tail(bd_limpia)
##        vcClaveTienda   DescGiro Codigo.Barras PLU      Fecha           Hora
## 107399         MX004 Carnicería  1.024877e+10  NA 15/10/2020 11:51:40 a. m.
## 167776         MX004 Carnicería  7.501080e+12  NA 15/10/2020 11:51:40 a. m.
## 149434         MX004 Carnicería  7.501055e+12  NA 15/10/2020 11:54:37 a. m.
## 168755         MX004 Carnicería  7.501214e+12  NA 15/10/2020 11:56:52 a. m.
## 161198         MX004 Carnicería  7.501031e+12  NA 15/10/2020 12:01:54 p. m.
## 112975         MX004 Carnicería  7.500470e+07  NA 15/10/2020 12:02:36 p. m.
##                 Marca           Fabricante                       Producto
## 107399         YEMINA               HERDEZ    PASTA SPAGHETTI YEMINA 200G
## 167776     DEL FUERTE ALIMENTOS DEL FUERTE PURE DE TOMATE DEL FUERTE 345G
## 149434 COCA COLA ZERO            COCA COLA           COCA COLA ZERO 600ML
## 168755       DIAMANTE           EMPACADOS              ARROZ DIAMANTE225G
## 161198          PEPSI  PEPSI-COLA MEXICANA              PEPSI N. R. 500ML
## 112975      COCA COLA            COCA COLA     COCA COLA RETORNABLE 500ML
##        Precio Ult.Costo Unidades F.Ticket NombreDepartamento
## 107399      7      5.38        2   450032          Abarrotes
## 167776     12      9.23        1   450032          Abarrotes
## 149434     15     11.54        2   450034          Abarrotes
## 168755     11      8.46        1   450037          Abarrotes
## 161198     10      7.69        1   450039          Abarrotes
## 112975     10      7.69        8   450040          Abarrotes
##               NombreFamilia               NombreCategoria  Estado Mts.2
## 107399       Sopas y Pastas Fideos, Spaguetti, Tallarines Sinaloa    53
## 167776 Salsas y Sazonadores          Salsa para Spaguetti Sinaloa    53
## 149434              Bebidas         Refrescos Retornables Sinaloa    53
## 168755    Granos y Semillas                         Arroz Sinaloa    53
## 161198              Bebidas     Refrescos Plástico (N.R.) Sinaloa    53
## 112975              Bebidas         Refrescos Retornables Sinaloa    53
##        Tipo.ubicación      Giro Hora.inicio Hora.cierre
## 107399        Esquina Abarrotes        7:00       23:00
## 167776        Esquina Abarrotes        7:00       23:00
## 149434        Esquina Abarrotes        7:00       23:00
## 168755        Esquina Abarrotes        7:00       23:00
## 161198        Esquina Abarrotes        7:00       23:00
## 112975        Esquina Abarrotes        7:00       23:00

c. Generar Basket

#install.packages("plyr")
library(plyr)
basket<- ddply(bd_limpia,c("F.Ticket"),function(bd_limpia)paste(bd_limpia$Marca,collapse=","))

d. Eliminar numero de ticket

basket$F.Ticket<-NULL

e. Eliminar renombramos el nombre de la columna

colnames(basket) <-c("Marca")

f. Exportar basket

#write.csv(basket,"abarrotesbasket.csv", quote =FALSE, row.names =FALSE)

Paso 3. Importar transacciones

#file.choose()
tr <- read.transactions("C:\\Users\\danyc\\OneDrive - Instituto Tecnologico y de Estudios Superiores de Monterrey\\Desktop\\Excel y CSV\\abarrotesbasket.csv", format = "basket", sep = ",")
## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string
## Warning in asMethod(object): removing duplicated items in transactions

Paso 4. Creamos una regla de asociación

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 ...[604 item(s), 115111 transaction(s)] done [0.29s].
## sorting and recoding items ... [207 item(s)] done [0.01s].
## creating transaction tree ... done [0.22s].
## checking subsets of size 1 2 3 done [0.01s].
## writing ... [11 rule(s)] done [0.00s].
## creating S4 object  ... done [0.06s].
summary(reglas.asociacion)
## set of 11 rules
## 
## rule length distribution (lhs + rhs):sizes
##  2 
## 11 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       2       2       2       2       2       2 
## 
## summary of quality measures:
##     support           confidence        coverage             lift       
##  Min.   :0.001016   Min.   :0.2069   Min.   :0.003562   Min.   : 1.325  
##  1st Qu.:0.001103   1st Qu.:0.2356   1st Qu.:0.004504   1st Qu.: 1.787  
##  Median :0.001416   Median :0.2442   Median :0.005803   Median : 3.972  
##  Mean   :0.001519   Mean   :0.2536   Mean   :0.006054   Mean   :17.563  
##  3rd Qu.:0.001651   3rd Qu.:0.2685   3rd Qu.:0.006893   3rd Qu.:21.798  
##  Max.   :0.002745   Max.   :0.3098   Max.   :0.010503   Max.   :65.908  
##      count      
##  Min.   :117.0  
##  1st Qu.:127.0  
##  Median :163.0  
##  Mean   :174.9  
##  3rd Qu.:190.0  
##  Max.   :316.0  
## 
## mining info:
##  data ntransactions support confidence
##    tr        115111   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 coverage   
## [1]  {FANTA}           => {COCA COLA} 0.001051159 0.2439516  0.004308884
## [2]  {SALVO}           => {FABULOSO}  0.001103283 0.3097561  0.003561779
## [3]  {FABULOSO}        => {SALVO}     0.001103283 0.2347505  0.004699811
## [4]  {COCA COLA ZERO}  => {COCA COLA} 0.001416025 0.2969035  0.004769310
## [5]  {SPRITE}          => {COCA COLA} 0.001346526 0.2069426  0.006506763
## [6]  {PINOL}           => {CLORALEX}  0.001016410 0.2363636  0.004300197
## [7]  {BLUE HOUSE}      => {BIMBO}     0.001711392 0.2720994  0.006289581
## [8]  {HELLMANN´S}      => {BIMBO}     0.001537646 0.2649701  0.005803094
## [9]  {REYMA}           => {CONVERMEX} 0.002093631 0.2441743  0.008574333
## [10] {FUD}             => {BIMBO}     0.001589770 0.2183771  0.007279930
## [11] {COCA COLA LIGHT} => {COCA COLA} 0.002745176 0.2613730  0.010502906
##      lift      count
## [1]   1.561906 121  
## [2]  65.908196 127  
## [3]  65.908196 127  
## [4]   1.900932 163  
## [5]   1.324955 155  
## [6]  25.030409 117  
## [7]   4.078870 197  
## [8]   3.971997 177  
## [9]  18.564824 241  
## [10]  3.273552 183  
## [11]  1.673447 316
?reglas.asociacion 
## No documentation for 'reglas.asociacion' in specified packages and libraries:
## you could try '??reglas.asociacion'
#La confianza es la que se edita en este caso

Paso 5. Graficar Resultados de Asociación

top10reglas <- head(reglas.asociacion, n=10, by="confidence")
plot(top10reglas, method ="graph" , engine = "htmlwidget")

Conclusión y Aprendizaje

Para el Market Basket de abarrotes hay algo muy específico ya que en estos tipos de tiendas usualmente no hay departamentos 100% establecidos por lo tanto la estrategia es un poco cambiante, pero por aquí podemos ver los resultados de nuestra canasta y podemos ver que relacionados están todos los productos para hacer un sándwich, lo cual nos indica que las personas que usualmente llevan productos Bimbo (Pan) también llevan las marcas de Hellman’s (mayonesa), Blue House (queso) y FUD (jamón). Esta sería una buena estrategia para también juntar estos productos y hacer un paquete promocional de todos estos productos.

La correlación más marcada dentro de la gráfica mostrada anteriormente es la de los productos Fabuloso con Salvo, esto tiene sentido ya que ambos son productos de limpieza y usualmente se utilizan para dos áreas de aseo diferente, por lo tanto se puede inferir que las personas que van a la tienda de abarrotes por productos de limpieza y toman un producto Fabuloso se llevarán uno Salvo o Viceversa.

Estos tipos de análisis que se realizan para estos tipos de tiendas son demasiado importantes a mi punto de vista ya que ayudan a manejar los productos y tener flujo para las cuentas por pagar debido a la movilización de los productos manteniendo así las tiendas a flote, claro esto si los datos se alimentan al software de la tienda de abarrotes e inclusive se puede utilizar como un beneficio para atraer a las personas al e-commerce de la tienda de abarrotes, si es que lo tiene e implementar estos descuentos en productos si se los llevan en paquete.

LS0tDQp0aXRsZTogPHNwYW4gc3R5bGU9IkNvbG9yOiNDMjMwMzAiPiJNYXJrZXQgQmFza2V0IEFiYXJyb3RlcyI8L3NwYW4+DQphdXRob3I6ICJEYW5pZWxhIEPDoXJkZW5hcyBaIC8vIEEwMTcyMDUzNSINCmRhdGU6ICIyMDIyLTA5LTIwIg0Kb3V0cHV0OiANCiAgICAgIGh0bWxfZG9jdW1lbnQ6DQogICAgICAgIHRvYzogdHJ1ZQ0KICAgICAgICB0b2NfZmxvYXQ6IHRydWUNCiAgICAgICAgY29kZV9mb2xkaW5nOiAiaGlkZSINCiAgICAgICAgY29kZV9kb3dubG9hZDogdHJ1ZQ0KLS0tDQoqKioNCg0KIyA8aW1nIHNyYz0gIkM6XFxVc2Vyc1xcZGFueWNcXERvd25sb2Fkc1xcYmFzay5qcGciIC8+DQoNCiMgPHNwYW4gc3R5bGU9IkNvbG9yOiNFRUQyMDIiPiBQYXNvIDEuIEltcG9ydGFyIGJhc2UgZGUgZGF0b3MgPC9zcGFuPg0KYGBge3J9DQoNCiNmaWxlLmNob29zZSgpDQoNCmJkX2xpbXBpYSA8LSByZWFkLmNzdiAoICJDOlxcVXNlcnNcXGRhbn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