————— CLUSTERING —————
Importando la data
fiscalizacion=read.csv("https://raw.githubusercontent.com/rladies/meetup-presentations_lima/master/20180315-RLadiesLima-Meetup2/Fiscalizacion.csv",sep = ";")
Visualizamos la data
head(fiscalizacion)
## N. FECHA UBICACIÓN NÚMERO.DE.INSPECTORES
## 1 1 - AV.JAVIER PRADO CON AV.NAVARRETE 2
## 2 2 - AV.PETIT THOUARS CON CA. CHINCHON 4
## 3 3 - AV.CAMINO REAL CON AV.CHOQUEHUANCA 4
## 4 4 - AV.JAVIER PRADO CON CA.LAS FLORES 4
## 5 5 - AV.SALAVERRY CON AV.SANCHEZ CARRION 4
## 6 6 - AV.CANAVAL MOREYRA CON AV.REPUBLICA DE PANAMA 3
## NÚMERO.DE.EFECTIVOS.POLICIALES TOTAL.DE.PAPELETAS.IMPUESTAS
## 1 7 9
## 2 3 1
## 3 3 1
## 4 3 6
## 5 5 7
## 6 4 7
## TRANSPORTE.PÚBLICO TRANSPORTE.PRIVADO
## 1 4 5
## 2 0 1
## 3 0 1
## 4 4 2
## 5 5 2
## 6 4 3
(selecciona data )
fiscalizacion1 = fiscalizacion
Seleccionamos data netamente numéricas para poder realizar el sacale.
fiscalizacion_num = fiscalizacion1[,4:8]
Se realiza esta función genérica para centrar o escalarlas columnas de una matriz numérica.
fiscalizacion1.scale<- as.data.frame(scale(fiscalizacion_num[,1:5]))
(Esta cosa tenía un significado xD)
wss=as.numeric()
for(k in 2:10){ #depende de la cantidad de cluster a armar, k=numero optimo de cluster
set.seed(111) #Estableciendo la semilla para determinar los centroides
grupos = kmeans(fiscalizacion1[,4:8],k) #distritos[filas,columnas], kmeans(data, #de cluster, método)
wss[k-1]=grupos$tot.withinss #$tot.withinss -> totalidad de lo grupos
}
(Nos ayuda a seleccionar la cantidad de grupos que realizaremos, donde veamos el punto de quiebre, en este caso es de 3, como se muestra en el gráfico)
plot(2:10,wss,type="b")
Generando el mismo gráfico de codo con la libreria factor extra, para obtener de manera más específica los grupos que se deben realizar
library(factoextra)
## Loading required package: ggplot2
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
fviz_nbclust(fiscalizacion1[,4:8], kmeans, method = "wss")
Según los gráficos se debería generar 2 grupos aunque tambien sugiere un tercer grupo, se construira con 2 y 3 grupos para comparar resultados.
grupos2 = kmeans(fiscalizacion1[,4:8],2)
grupos3 = kmeans(fiscalizacion1[,4:8],3)
grupos4 = kmeans(fiscalizacion1[,4:8],4)
Comparando los grupos formados
table(grupos2$cluster)
##
## 1 2
## 16 126
table(grupos3$cluster)
##
## 1 2 3
## 21 118 3
table(grupos4$cluster)
##
## 1 2 3 4
## 3 53 14 72
Con porcentajes
prop.table(table(grupos2$cluster))
##
## 1 2
## 0.1126761 0.8873239
prop.table(table(grupos3$cluster))
##
## 1 2 3
## 0.14788732 0.83098592 0.02112676
prop.table(table(grupos4$cluster))
##
## 1 2 3 4
## 0.02112676 0.37323944 0.09859155 0.50704225
A partir de la comparativa se opta por generar 3 grupos, por que los grupos son mas homogeneos
Gráficamos los cluster optimos
library(cluster)
clusplot(fiscalizacion1[,4:8], grupos3$cluster)
Del grupos3 sacamos las medias, de ello se va a poder determinar las variables en los que exista una diferencia notoria entre los cluster.
grupos3
## K-means clustering with 3 clusters of sizes 21, 118, 3
##
## Cluster means:
## NÚMERO.DE.INSPECTORES NÚMERO.DE.EFECTIVOS.POLICIALES
## 1 3.285714 3.761905
## 2 1.118644 1.533898
## 3 5.333333 6.666667
## TOTAL.DE.PAPELETAS.IMPUESTAS TRANSPORTE.PÚBLICO TRANSPORTE.PRIVADO
## 1 8.142857 4.0000000 4.142857
## 2 2.347458 0.6355932 1.711864
## 3 19.666667 5.0000000 14.666667
##
## Clustering vector:
## [1] 1 2 2 1 1 1 1 2 1 2 1 1 2 3 1 3 2 1 2 1 2 1 2 1 2 3 1 2 2 2 2 2 2 2 2 2 1
## [38] 2 2 1 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 1 2
## [75] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2
## [112] 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
##
## Within cluster sum of squares by cluster:
## [1] 405.23810 507.99153 94.66667
## (between_SS / total_SS = 71.2 %)
##
## Available components:
##
## [1] "cluster" "centers" "totss" "withinss" "tot.withinss"
## [6] "betweenss" "size" "iter" "ifault"
Diagrama de dispersión por cluster
plot(fiscalizacion1$TOTAL.DE.PAPELETAS.IMPUESTAS, fiscalizacion1$TRANSPORTE.PÚBLICO, col = grupos3$cluster)
Diagrama de dispersión por cluster
plot(fiscalizacion1$TRANSPORTE.PRIVADO, fiscalizacion1$TOTAL.DE.PAPELETAS.IMPUESTAS, col = grupos3$cluster)
Para identificar los elementos en cada cluster
# plot(fiscalizacion1$TRANSPORTE.PRIVADO, fiscalizacion1$TOTAL.DE.PAPELETAS.IMPUESTAS, col = grupos3$cluster)
# identify(x=fiscalizacion1$TRANSPORTE.PRIVADO,
# y=fiscalizacion1$TOTAL.DE.PAPELETAS.IMPUESTAS,
# fiscalizacion1$X)
Para graficarlo en 3d, para ello se debe tomar en cuenta una variable mas para el eje Z
# library(rgl)
# open3d()
# plot3D(x=fiscalizacion1$TRANSPORTE.PRIVADP,
# y=fiscalizacion1$fiscalizacion1$TOTAL.DE.PAPELETAS.IMPUESTAS,
# z=fiscalizacion1$FECHA,
# col=grupos3$cluster, size=20)
# movie3d(spin3d(), duration = 50)
————— REGLAS DE ASOCIACIÓN —————
Importando la data *Instalamos el paquete arules el cual permitirá ver transacciones
# install.packages("arules")
library(arules)
## Loading required package: Matrix
##
## Attaching package: 'arules'
## The following objects are masked from 'package:base':
##
## abbreviate, write
fi_csv = read.csv("https://raw.githubusercontent.com/rladies/meetup-presentations_lima/master/20180315-RLadiesLima-Meetup2/Fiscalizacion.csv",sep=";")
fis = read.transactions("https://raw.githubusercontent.com/rladies/meetup-presentations_lima/master/20180315-RLadiesLima-Meetup2/Fiscalizacion.csv",sep=";")
## Warning in asMethod(object): removing duplicated items in transactions
head(fis)
## transactions in sparse format with
## 6 transactions (rows) and
## 339 items (columns)
fis_1 = fis[2:125,]
Hacemos summary a dist ya que esta funcion brinda informacion sobre la matriz importada
summary(fis_1)
## transactions as itemMatrix in sparse format with
## 124 rows (elements/itemsets/transactions) and
## 339 columns (items) and a density of 0.01798458
##
## most frequent items:
## 1 2 0 3 - (Other)
## 101 76 64 52 47 416
##
## element (itemset/transaction) length distribution:
## sizes
## 5 6 7 8
## 34 54 26 10
##
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 5.000 5.000 6.000 6.097 7.000 8.000
##
## includes extended item information - examples:
## labels
## 1 -
## 2 0
## 3 1
0.1470588*100
## [1] 14.70588
De ello se interpreta lo siguiente:
El valor de densidad de 0.01798458 (1.798 %) se refieere a la proporción de celdas en la matriz que son distintas de cero. Dado que hay 124 * 339 = 42036 celdas en la matriz, es posible calcular el número total 42036 * 0.03738318 = 42036 de ítems. ———————————————————————————– En el siguiente bloque de la salidad de summary() se muestran los items más frecuentes encontrados en la base de datos de transacciones. 1) Dado que 5/34 = 0.1470588, podemos determinar que epresenta un 14,70% del total de registros, ———————————————————————————– Finalmente, se presentan un conjunto de estadísticas sobre el tamaño de los registros, Un total de 35 registros contienen 8 items.
Mostramos los registro realizados
labels(fis_1)
## [1] "{-,1,2,4,5,7,9,AV.JAVIER PRADO CON AV.NAVARRETE}"
## [2] "{-,0,1,2,3,4,AV.PETIT THOUARS CON CA. CHINCHON}"
## [3] "{-,0,1,3,4,AV.CAMINO REAL CON AV.CHOQUEHUANCA}"
## [4] "{-,2,3,4,6,AV.JAVIER PRADO CON CA.LAS FLORES}"
## [5] "{-,2,4,5,7,AV.SALAVERRY CON AV.SANCHEZ CARRION}"
## [6] "{-,3,4,6,7,AV.CANAVAL MOREYRA CON AV.REPUBLICA DE PANAMA}"
## [7] "{-,2,3,4,5,7,AV.CANAVAL MOREYRA CON AV.PASEO DE LA REPUBLICA}"
## [8] "{-,1,2,8,AV.DOS DE MAYO CON AV.ARENALES}"
## [9] "{-,1,2,3,6,7,9,AV.GUARDIA CIVIL CON AV.GALVEZ BARRENECHEA}"
## [10] "{-,10,2,3,5,AV.JAVIER PRADO CON CA.LAS PALMERAS}"
## [11] "{-,11,12,3,4,5,9,Av. Javier Prado con Av. Navarrete}"
## [12] "{-,10,12,2,3,4,6,Calle Federico Villarreal con Calle Chinchon}"
## [13] "{-,0,13,2,Av. Camino Real con Av.Choquehuanca}"
## [14] "{-,13,14,17,4,7,Av. Javier Prado con Av. Las Flores}"
## [15] "{-,12,15,3,4,9,Av. Salaverry con Av. Sanchez Carrion}"
## [16] "{-,1,16,17,18,4,5,Av. Canaval Moreyra con Paseo de la Republica}"
## [17] "{-,1,17,2,Av. Canaval Moreyra con Republica de Panamá}"
## [18] "{-,13,18,4,5,6,7,Av Javier Prado con Av. Las Palmeras}"
## [19] "{-,1,19,2,3,Av Javier Prado con Paseo Parodi}"
## [20] "{-,2,20,5,7,9,Av. Javier Prado con Av. Palmeras}"
## [21] "{-,0,1,2,21,Av. Javier Prado con Av. Navarrete}"
## [22] "{-,11,22,3,4,5,6,AV. Carriquiry con Calle Ruiseñores}"
## [23] "{-,0,2,23,3,Av. Canaval Moreyra con Av. Paseo de la República}"
## [24] "{-,24,3,4,5,6,7,AV.CANAVAL MOREYRA CON AV.PASEO DE LA REPUBLICA}"
## [25] "{-,1,2,25,3,Av. Carriquirri con Av. Ruiseñores}"
## [26] "{-,10,14,24,26,8,Av. Petit Thouars con Av. Juan de Arona}"
## [27] "{-,27,3,4,6,7,8,Av. Salaverry con Av. Sanchez Carrion}"
## [28] "{-,1,2,28,AV. BASADRE CON CA.LAS FLORES}"
## [29] "{-,1,29,3,4,AV.JAVIER PRADO CON CA.LAS PALMERAS}"
## [30] "{-,1,2,3,30,AV.DOS DE MAYO CON AV.ARENALES}"
## [31] "{-,1,3,31,4,CA.CHINCHON CON CA.AUDIENCIA}"
## [32] "{-,0,1,32,4,AV.CANAVAL MOREYRA CON AV.PASEO DE LA REPUBLICA}"
## [33] "{-,1,2,3,33,4,AV.CARRIQUIRY CON CA.RUISEÑORES}"
## [34] "{-,1,2,3,34,4,AV.GUARDIA CIVIL CON CA.RICARDO ANGULO}"
## [35] "{-,0,1,35,4,AV.GALVEZ BARRENECHEA(CDRA 3)}"
## [36] "{-,0,1,2,36,AV.SALAVERRY CON AV.SANCHEZ CARRION}"
## [37] "{-,1,2,37,4,6,AV.SALAVERRY CON ALBERTO DEL CAMPO}"
## [38] "{-,1,2,3,38,4,CA.FEDERICO VILLARREAL CON CA.CHINCHON}"
## [39] "{-,1,2,3,39,AV.ARAMBURU CON AV.PETIT THOUARS}"
## [40] "{-,4,40,5,9,AV.JAVIER PRADO CON AV.ARENALES}"
## [41] "{-,1,2,4,41,5,AV.BARRENECHEA CON AV.DEL PARQUE NORTE}"
## [42] "{-,0,1,3,42,CA.ANDRES REYES CON FELIPE VILLARAN}"
## [43] "{-,0,1,3,43,AV.PASEO DE LA REPUBLICA CON AV.CANAVAL MOREYRA}"
## [44] "{-,0,1,2,44,AV.JAVIER PRADO ESTE}"
## [45] "{-,1,3,4,45,AV.SALAVERRY CON AV SANCHEZ CARRION}"
## [46] "{-,1,2,3,46,7,8,AV.PEREZ ARANIBAR CON AV.CORONEL PORTILLO}"
## [47] "{-,0,1,47,AV.PEZET CON AV.PORTILLO}"
## [48] "{0,1,1/19/16,2,4,48,AV.JAVIER PRADO OESTE CON AV.NAVARRETE}"
## [49] "{1,1/20/16,2,4,49,AV.JAVIER PRADO OESTE CON AV.NAVARRETE}"
## [50] "{0,1,1/21/16,2,50,AV.JAVIER PRADO OESTE CON AV.PASEO PARODI}"
## [51] "{1,1/22/16,2,3,4,51,AV.JAVIER PRADO OESTE CON AV.PASEO PARODI}"
## [52] "{1,1/25/16,2,52,AV.JAVIER PRADO OESTE CON AV.PASEO PARODI}"
## [53] "{1,1/26/16,2,3,53,AV.JAVIER PRADO CON AV.PETIT THOUARS}"
## [54] "{0,1,1/27/16,2,54,AV.JAVIER PRADO CON AV.PETIT THOUARS}"
## [55] "{0,1,1/28/16,4,55,AV.JAVIER PRADO CON AV.PETIT THOUARS}"
## [56] "{0,1,2/08/2016,56,AV.JAVIER PRADO OESTE CON AV.ARENALES}"
## [57] "{0,1,2,2/09/2016,57,AV.JAVIER PRADO OESTE CON CALLE PALMERAS}"
## [58] "{0,1,2,2/10/2016,58,AV.JAVIER PRADO OESTE CON ARENALES}"
## [59] "{2,2/12/2016,3,5,59,AV.JAVIER PRADO OESTE CON CALLE PALMERAS}"
## [60] "{1,2,2/15/16,3,60,AV.JAVIER PRADO OESTE CON CALLE PALMERAS}"
## [61] "{2,2/16/16,4,6,61,AV.JAVIER PRADO OESTE CON AV.ARENALES}"
## [62] "{0,1,2,2/17/16,4,62,AV.JAVIER PRADO OESTE CON AV.ARENALES}"
## [63] "{0,2,2/19/16,4,63,AV.JAVIER PRADO OESTE CON AV.ARENALES}"
## [64] "{1,2,2/22/16,3,64,AV.JAVIER PRADO CON CALLE LAS FLORES}"
## [65] "{0,1,3/08/2016,65,AV.CANAVAL MOREYRA CON AV.REPUBLICA DE PANAMA}"
## [66] "{1,2,3,3/10/2016,66,AV.CANAVAL MOREYRA CON AV.REPUBLICA DE PANAMA}"
## [67] "{0,1,3/15/16,67,AV.CARRIQUIRY CON CALLE RUISEÑORES}"
## [68] "{1,2,3,3/21/16,68,AV.CARRIQUIRY CON CALLE RUISEÑORES}"
## [69] "{1,2,3/22/16,69,AV.CANAVAL MOREYRA CON AV.REPUBLICA DE PANAMA}"
## [70] "{1,2,3/23/16,70,AV.CANAVAL MOREYRA CON AV.REPUBLICA DE PANAMA}"
## [71] "{1,2,3,3/30/16,5,71,AV.CAMINO REAL CON CA.CHOQUEHUANCA}"
## [72] "{0,2,3,3/31/16,72,AV.MIROQUESADA CON AV PORTILLO}"
## [73] "{0,2,4/01/2016,7,73,AV.DOS DE MAYO CON CALLE LAS PALMERAS}"
## [74] "{0,1,4/13/16,74,AV.REPUBLICA DE PANAMA CON CALLE OROPENDOLAS}"
## [75] "{0,1,3,4/15/16,75,AV.CANAVAL MOREYRA CON AV.PABLO CARRIQUIRY}"
## [76] "{1,2,3,4/18/16,76,AV.REPUBLICA DE PANAMA CON AV.CANAVAL MOREYRA}"
## [77] "{0,1,2,4/19/16,77,AV.REPUBLICA DE PANAMA CON AV.CANAVAL MOREYRA}"
## [78] "{1,2,3,4,4/20/16,78,AV.REPUBLICA DE PANAMA CON AV.CANAVAL MOREYRA}"
## [79] "{0,1,4/22/16,79,AV.REPUBLICA DE PANAMA CON CALLE TORDILLAS}"
## [80] "{0,1,4/25/16,80,AV.CANAVAL MOREYRA CON AV.PASEO DE LA REPUBLICA}"
## [81] "{0,1,4/26/16,81,AV CANAVAL MOREYRA CON AV REPUBLICA DE PANAMA}"
## [82] "{0,1,4/28/16,82,AV REPUBLICA DE PANAMA CON AV CANAVAL MOREYRA}"
## [83] "{0,1,5/09/2016,83,AV.GUARDIA CIVIL CON CALLE RICARDO ANGULO}"
## [84] "{0,1,2,5/12/2016,84,AV.PARQUE SUR CON AV.GUARDIA CIVIL}"
## [85] "{0,1,5/17/16,85,AV.PARQUE NORTE CON AV.GUARDIA CIVIL}"
## [86] "{0,1,2,5/20/16,86,AV.PARQUE NORTE CON AV.GUARDIA CIVIL}"
## [87] "{0,1,5/25/16,87,AV.PARQUE NORTE CON AV.BARRENECHEA}"
## [88] "{0,1,2,6/20/16,88,AV JAVIER PRADO CON CALLE LAS PALMERAS}"
## [89] "{0,1,2,6/21/16,89,AV DOS DE MAYO CON CALLE LAS PALMERAS}"
## [90] "{0,1,6/22/16,90,AV DOS DE MAYO CON CALLE LAS PALMERAS}"
## [91] "{0,1,2,6/23/16,91,AV ARAMBURU CON AV PETIT THOUARS}"
## [92] "{0,1,2,6/27/16,92,AV ARAMBURU CON AV PETIT THOUARS}"
## [93] "{1,2,3,5,7/07/2016,93,AV.REPUBLICA DE PANAMA CON CALLE MIGUEL SEMINARIO}"
## [94] "{0,1,7/11/2016,94,AV.DOS DE MAYO CON CALLE LAS PALMERAS}"
## [95] "{0,1,7/12/2016,95,AV.DOS DE MAYO CON CALLE LAS PALMERAS}"
## [96] "{0,1,2,7/14/16,96,AV.CANAVAL Y MOREYRA CON AV.PASEO DE LA REPUBLICA}"
## [97] "{1,2,3,7/15/16,97,AV.CANAVAL Y MOREYRA CON AV.PASEO DE LA REPUBLICA}"
## [98] "{0,1,7/18/16,98,AV.CANAVAL Y MOREYRA CON AV.PASEO DE LA REPÚBLICA}"
## [99] "{1,2,4,6,8/11/2016,99,AV.CAMINO REAL CON CALLE CHOQUEHUANCA}"
## [100] "{1,100,2,8/15/16,AV.JAVIER PRADO CON AV.JUAN DE ALIAGA}"
## [101] "{0,1,101,8/18/16,AV.JAVIER PRADO CON AV.JUAN DE ALIAGA}"
## [102] "{0,1,102,8/19/16,AV.JUAN DE ARONA CON AV.PETIT THOUARS}"
## [103] "{0,1,103,8/23/16,AV.JUAN DE ARONA CON AV.PETIT THOUARS}"
## [104] "{1,104,2,3,9/21/16,AV. PARQUE NORTE CON AV. BARRENECHEA}"
## [105] "{1,105,2,3,4,9/22/16,CALLE RICARDO ANGULO CON CALLE 41}"
## [106] "{1,106,2,9/23/16,AV. PARQUE NORTE CON CALLE RICARDO ANGULO}"
## [107] "{0,1,10/11/2016,107,2,AV. CANAVAL Y MOREYRA CON AV. PASEO DE LA REPÚBLICA}"
## [108] "{0,1,10/12/2016,108,2,3,AV. CANAVAL Y MOREYRA CON AV. PASEO DE LA REPÚBLICA}"
## [109] "{0,1,10/13/16,109,AV. JUAN DE ARONA CON AV. NAVARRETE}"
## [110] "{0,1,10/14/16,110,AV.DOS DE MAYO CON CALLE LAS PALMERAS}"
## [111] "{0,1,10/17/16,111,2,3,AV.DOS DE MAYO CON CALLE LAS PALMERAS}"
## [112] "{0,1,10/18/16,112,2,AV.DOS DE MAYO CON CALLE LAS PALMERAS}"
## [113] "{0,1,10/19/16,113,3,AV.DOS DE MAYO CON CALLE LAS PALMERAS}"
## [114] "{0,1,10/21/16,114,AV.CARRIQUIRY CON CALLE RUISEÑORES}"
## [115] "{0,1,10/24/16,115,AV.CARRIQUIRY CON CALLE RUISEÑORES}"
## [116] "{0,1,11/28/16,116,CA.CHOQUEHUANCA CON CA. CAMINO REAL}"
## [117] "{0,1,117,12/19/16,3,7,CA.CHOQUEHUANCA CON CA. CAMINO REAL}"
## [118] "{1,118,17/01/2017,2,3,5,AV. BARRENECHEA Cdra. 4}"
## [119] "{0,1,119,13/02/2017,AV. ARONA CON CA. VILLARREAL}"
## [120] "{1,120,14/02/2017,2,3,AV. ARONA CON CA. VILLARREAL}"
## [121] "{0,1,121,15/02/2017,2,3,AV. ARONA CON CA. VILLARREAL}"
## [122] "{0,1,122,16/02/2017,2,3,AV. ARONA CON CA. VILLARREAL}"
## [123] "{1,123,17/02/2017,2,3,AV. ARONA CON CA. VILLARREAL}"
## [124] "{0,1,124,2,21/02/2017,5,AV. JAVIER PRADO CON CA. CASTAÑOS}"
Visualizamos el soporte de los items (p. ej. de aquellos items con una proporción mayor a 0.10)
itemFrequencyPlot(fis_1, support = 0.1)
Visualizamos el soporte de los items (p. ej.de los 20 ítems con mayor soporte)
itemFrequencyPlot(fis_1, topN = 20)
Visualizamos la matriz de transacciones (p. ej. para las 5 primeras transacciones)
image(fis_1[1:5])
Visualizamos la matriz de transacciones (p. ej. para las 20 primeras transacciones)
image(sample(fis_1, 20))
#Entrenar el modelo con los datos
Usar la funcion apriore permite establecer la confianza y definir el minimo de elementos para cada regla)
help(apriori)
## starting httpd help server ... done
apriori(fis_1)
## Apriori
##
## Parameter specification:
## confidence minval smax arem aval originalSupport maxtime support minlen
## 0.8 0.1 1 none FALSE TRUE 5 0.1 1
## maxlen target ext
## 10 rules FALSE
##
## Algorithmic control:
## filter tree heap memopt load sort verbose
## 0.1 TRUE TRUE FALSE TRUE 2 TRUE
##
## Absolute minimum support count: 12
##
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[284 item(s), 124 transaction(s)] done [0.00s].
## sorting and recoding items ... [8 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 4 done [0.00s].
## writing ... [6 rule(s)] done [0.00s].
## creating S4 object ... done [0.00s].
## set of 6 rules
Definiendo soporte, confiaza y minimo de elementos para obtener las reglas
fisrules <- apriori(fis_1, parameter = list(support =0.1,confidence = 0.8, minlen = 1))
## Apriori
##
## Parameter specification:
## confidence minval smax arem aval originalSupport maxtime support minlen
## 0.8 0.1 1 none FALSE TRUE 5 0.1 1
## maxlen target ext
## 10 rules FALSE
##
## Algorithmic control:
## filter tree heap memopt load sort verbose
## 0.1 TRUE TRUE FALSE TRUE 2 TRUE
##
## Absolute minimum support count: 12
##
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[284 item(s), 124 transaction(s)] done [0.00s].
## sorting and recoding items ... [8 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 4 done [0.00s].
## writing ... [6 rule(s)] done [0.00s].
## creating S4 object ... done [0.00s].
fisrules
## set of 6 rules
summary(fisrules)
## set of 6 rules
##
## rule length distribution (lhs + rhs):sizes
## 1 2 3
## 1 2 3
##
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.000 2.000 2.500 2.333 3.000 3.000
##
## summary of quality measures:
## support confidence lift count
## Min. :0.1371 Min. :0.8108 Min. :0.9955 Min. : 17.00
## 1st Qu.:0.2117 1st Qu.:0.8181 1st Qu.:1.0044 1st Qu.: 26.25
## Median :0.3589 Median :0.8311 Median :1.0204 Median : 44.50
## Mean :0.3965 Mean :0.8432 Mean :1.2351 Mean : 49.17
## 3rd Qu.:0.5000 3rd Qu.:0.8458 3rd Qu.:1.1046 3rd Qu.: 62.00
## Max. :0.8145 Max. :0.9219 Max. :2.2426 Max. :101.00
##
## mining info:
## data ntransactions support confidence
## fis_1 124 0.1 0.8