Percentage of population employed in different industries in Europian countries during 1979. The purpose of examining this data is to get insights into patterns of employment (if any) amongst European countries in 1970s.
Loading Libraries
library(data.table)
library(gridExtra)
library(factoextra)
library(tidyverse)
library(knitr)
Loading Data
data <- fread("https://www.dropbox.com/s/i54o2y9t3io88af/europeanJobs.txt?dl=1")
set.seed(12871014)
# randomly select 90% of the data
index <- sample(nrow(data), size = 0.9*nrow(data))
subset <- data[index,]
Visualizing for all clusters
Visualizing data for different clusters on first two principal components
k2 <- kmeans(subset[,-1], centers = 2, nstart = 25)
k3 <- kmeans(subset[,-1], centers = 3, nstart = 25)
k4 <- kmeans(subset[,-1], centers = 4, nstart = 25)
k5 <- kmeans(subset[,-1], centers = 5, nstart = 25)
# plots to compare
p1 <- fviz_cluster(k2, geom = "point", data = subset[,-1]) + ggtitle("k = 2")
p2 <- fviz_cluster(k3, geom = "point", data = subset[,-1]) + ggtitle("k = 3")
p3 <- fviz_cluster(k4, geom = "point", data = subset[,-1]) + ggtitle("k = 4")
p4 <- fviz_cluster(k5, geom = "point", data = subset[,-1]) + ggtitle("k = 5")
grid.arrange(p1, p2, p3, p4, nrow = 2)
Determining number of clusters
Plotting Within Cluster Sum of Squares vs Cluster Size. Cluster size = 3 seems to be appropriate.
# within cluster sum of squares
wss <- c()
for (i in 1:12)
{
# calculating total wss for each cluster size with 25 random iterations for each
wss[i] <- sum(kmeans(subset[,-1], centers=i, nstart = 25)$withinss)
}
# plotting wss vs number of clusters
plot(1:12, wss, type="b", xlab="Number of Clusters",ylab="Within groups sum of squares")
Plotting R-Square vs Cluster Size. Cluster size = 3 seems to be appropriate.
# r-square
r_square <- c()
for (i in 1:12)
{
# calculating total between sum square for each cluster size
bss <- sum(kmeans(subset[,-1], centers=i, nstart = 25)$betweenss)
# calculating total sum square for each cluster size
tss <- sum(kmeans(subset[,-1], centers=i, nstart = 25)$totss)
r_square[i] <- bss/tss
}
# plotting wss vs number of clusters
plot(1:12, r_square, type="b", xlab="Number of Clusters",ylab="R-Square")
Running K-Means Clustering for 3 clusters
kmeans_clustering <- kmeans(subset[,-1], centers=3, nstart=25)
fviz_cluster(kmeans_clustering, data = subset[,-1])
Interpretting Clusters
Cluster 1: Developed Countries - Most of the population is either employed in service industry, social/personal services or manufacturing.
Cluster 2: Underdeveloped Countries - Most of the population is employed in agriculture industry.
Cluster 3: Developing Countries - Most of the population is employed in agriculture or manufacturing industry.
centers_df <- round(as.data.frame(kmeans_clustering$centers))
centers_df$cluster <- rownames(centers_df)
centers_df <- select(centers_df, cluster, everything())
kable(centers_df)
| cluster | Agr | Min | Man | PS | Con | SI | Fin | SPS | TC |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 8 | 1 | 29 | 1 | 8 | 16 | 5 | 24 | 7 |
| 2 | 52 | 1 | 14 | 1 | 5 | 8 | 5 | 9 | 5 |
| 3 | 24 | 2 | 28 | 1 | 8 | 10 | 1 | 18 | 7 |
Interpretting Clusters
Most of the European Nations are either developed or developing. A handful of countries like Yugoslavia, Greece and Turkey are still under-developed.
subset$cluster <- kmeans_clustering$cluster
kable(arrange(subset, cluster))
| Country | Agr | Min | Man | PS | Con | SI | Fin | SPS | TC | cluster |
|---|---|---|---|---|---|---|---|---|---|---|
| Luxembourg | 7.7 | 3.1 | 30.8 | 0.8 | 9.2 | 18.5 | 4.6 | 19.2 | 6.2 | 1 |
| EGermany | 4.2 | 2.9 | 41.2 | 1.3 | 7.6 | 11.2 | 1.2 | 22.1 | 8.4 | 1 |
| WGermany | 6.7 | 1.3 | 35.8 | 0.9 | 7.3 | 14.4 | 5.0 | 22.3 | 6.1 | 1 |
| Belgium | 3.3 | 0.9 | 27.6 | 0.9 | 8.2 | 19.1 | 6.2 | 26.6 | 7.2 | 1 |
| UK | 2.7 | 1.4 | 30.2 | 1.4 | 6.9 | 16.9 | 5.7 | 28.3 | 6.4 | 1 |
| Netherlands | 6.3 | 0.1 | 22.5 | 1.0 | 9.9 | 18.0 | 6.8 | 28.5 | 6.8 | 1 |
| France | 10.8 | 0.8 | 27.5 | 0.9 | 8.9 | 16.8 | 6.0 | 22.6 | 5.7 | 1 |
| Switzerland | 7.7 | 0.2 | 37.8 | 0.8 | 9.5 | 17.5 | 5.3 | 15.4 | 5.7 | 1 |
| Sweden | 6.1 | 0.4 | 25.9 | 0.8 | 7.2 | 14.4 | 6.0 | 32.4 | 6.8 | 1 |
| Norway | 9.0 | 0.5 | 22.4 | 0.8 | 8.6 | 16.9 | 4.7 | 27.6 | 9.4 | 1 |
| Denmark | 9.2 | 0.1 | 21.8 | 0.6 | 8.3 | 14.6 | 6.5 | 32.2 | 7.1 | 1 |
| Finland | 13.0 | 0.4 | 25.9 | 1.3 | 7.4 | 14.7 | 5.5 | 24.3 | 7.6 | 1 |
| Austria | 12.7 | 1.1 | 30.2 | 1.4 | 9.0 | 16.8 | 4.9 | 16.8 | 7.0 | 1 |
| Yugoslavia | 48.7 | 1.5 | 16.8 | 1.1 | 4.9 | 6.4 | 11.3 | 5.3 | 4.0 | 2 |
| Greece | 41.4 | 0.6 | 17.6 | 0.6 | 8.1 | 11.5 | 2.4 | 11.0 | 6.7 | 2 |
| Turkey | 66.8 | 0.7 | 7.9 | 0.1 | 2.8 | 5.2 | 1.1 | 11.9 | 3.2 | 2 |
| Bulgaria | 23.6 | 1.9 | 32.3 | 0.6 | 7.9 | 8.0 | 0.7 | 18.2 | 6.7 | 3 |
| Ireland | 23.2 | 1.0 | 20.7 | 1.3 | 7.5 | 16.8 | 2.8 | 20.8 | 6.1 | 3 |
| USSR | 23.7 | 1.4 | 25.8 | 0.6 | 9.2 | 6.1 | 0.5 | 23.6 | 9.3 | 3 |
| Portugal | 27.8 | 0.3 | 24.5 | 0.6 | 8.4 | 13.3 | 2.7 | 16.7 | 5.7 | 3 |
| Rumania | 34.7 | 2.1 | 30.1 | 0.6 | 8.7 | 5.9 | 1.3 | 11.7 | 5.0 | 3 |
| Hungary | 21.7 | 3.1 | 29.6 | 1.9 | 8.2 | 9.4 | 0.9 | 17.2 | 8.0 | 3 |
| Czechoslovakia | 16.5 | 2.9 | 35.5 | 1.2 | 8.7 | 9.2 | 0.9 | 17.9 | 7.0 | 3 |
Running Hierarchical Clustering using Ward’s Method
Ward’s Method iteratively combines clusters that minimize the within cluster sum of squares
# Calculate the distance matrix
distance <- dist(subset[,-1])
#Obtain clusters using the Wards method
hierarchical_clustering <- hclust(distance, method="ward.D")
plot(hierarchical_clustering)
Interpretting Clusters
Cluster 1: Developing Countries - Most of the population is employed in agriculture or manufacturing industry.
Cluster 2: Developed Countries - Most of the population is either employed in service industry, social/personal services or manufacturing.
Cluster 3: Underdeveloped Countries - Most of the population is employed in agriculture industry.
Note: Interpretation remains same, however, the cluster numbering changes
#Cut dendrogram at the 3 clusters level and obtain cluster membership
hierarchical_clustering_3_clusters = cutree(hierarchical_clustering,k=3)
subset$cluster <- hierarchical_clustering_3_clusters
subset[,-1] %>%
group_by(cluster) %>%
summarise_all(funs(mean)) %>%
round() %>%
kable()
| cluster | Agr | Min | Man | PS | Con | SI | Fin | SPS | TC |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 24 | 2 | 28 | 1 | 8 | 10 | 1 | 18 | 7 |
| 2 | 8 | 1 | 29 | 1 | 8 | 16 | 5 | 24 | 7 |
| 3 | 52 | 1 | 14 | 1 | 5 | 8 | 5 | 9 | 5 |
About Cincinnati Zoo:
Goal of Project:
To Study buying and/or visiting behavior of Zoo members.
Data:
Food Table-Over 14,000 records of [Demographics + Email, Food items purchased, Dates of purchase(July,2010 through March,2011), Price of food item purchased]
Loading Libraries
library(data.table)
library(tidyverse)
library(knitr)
library(arules)
library(arulesViz)
Loading Data
TransFood <- read.csv('https://xiaoruizhu.github.io/Data-Mining-R/data/food_4_association.csv')
TransFood <- TransFood[, -1]
# Find out elements that are not equal to 0 or 1 and change them to 1.
Others <- which(!(as.matrix(TransFood) ==1 | as.matrix(TransFood) ==0), arr.ind=T )
TransFood[Others] <- 1
# converting to spare format
TransFood <- as(as.matrix(TransFood), "transactions")
Exploring Data
Summary of Data
summary(TransFood)
## transactions as itemMatrix in sparse format with
## 19076 rows (elements/itemsets/transactions) and
## 118 columns (items) and a density of 0.02230729
##
## most frequent items:
## Bottled.WaterFood Slice.of.CheeseFood Medium.DrinkFood
## 3166 3072 2871
## Small.DrinkFood Slice.of.PeppFood (Other)
## 2769 2354 35981
##
## element (itemset/transaction) length distribution:
## sizes
## 0 1 2 3 4 5 6 7 8 9 10 11 12 13 15
## 197 5675 5178 3253 2129 1293 655 351 178 95 42 14 8 7 1
##
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 1.000 2.000 2.632 4.000 15.000
##
## includes extended item information - examples:
## labels
## 1 Add.CheeseFood
## 2 BeerFood
## 3 Bottled.WaterFood
Frequently bought items
itemFrequencyPlot(TransFood, support = 0.1, cex.names=0.8)
Basket containing more than 13 items
x = TransFood[size(TransFood) > 13]
inspect(x)
## items
## [1] {Bottled.WaterFood,
## CheeseburgerFood,
## ChipsFood,
## French.Fries.BasketFood,
## GatoradeFood,
## Gourmet.CupFood,
## Ice.Cream.ConeFood,
## Krazy.KritterFood,
## Medium.DrinkFood,
## SandwichFood,
## Slice.of.CheeseFood,
## Slice.of.PeppFood,
## Small.DrinkFood,
## Soft.Pretzel..3_39Food,
## Souvenir.DrinkFood}
Running Apriori Algorithm to determine association rules
Support: The support of an itemset X is defined as the proportion of transactions in the data set which contain the itemset. In the zoo data, the support for the rules is relatively low, with a maximum support of no more than 3%.
Confidence: The confidence of a rule is defined as conf(X->Y)=supp(XUY)/supp(X). For example, the rule {milk, bread} -> {butter} has a confidence of 0.5, which means that for 50% of the transactions containing milk and bread the rule is correct. Confidence can be interpreted as an estimate of the conditional probability P(Y |X), the probability of finding the RHS of the rule in transactions under the condition that these transactions also contain the LHS. Association rules are required to satisfy both a minimum support and a minimum confidence constraint at the same time.
Lift: Lift is a popular measure of to filter or rank found rules. The lift of a rule is defined as lift(X->Y)=supp(XUY)/(supp(X)*supp(Y)). Lift can be interpreted as the deviation of the support of the whole rule from the support expected under independence given the supports of the LHS and the RHS. Greater lift values indicate stronger associations.
Running the algorithm
# Run the apriori algorithm
basket_rules <- apriori(TransFood,parameter = list(sup = 0.003, conf = 0.5,target="rules"))
## Apriori
##
## Parameter specification:
## confidence minval smax arem aval originalSupport maxtime support minlen
## 0.5 0.1 1 none FALSE TRUE 5 0.003 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: 57
##
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[115 item(s), 19076 transaction(s)] done [0.01s].
## sorting and recoding items ... [74 item(s)] done [0.00s].
## creating transaction tree ... done [0.01s].
## checking subsets of size 1 2 3 4 done [0.00s].
## writing ... [42 rule(s)] done [0.00s].
## creating S4 object ... done [0.00s].
Summary of the algorithm
summary(basket_rules)
## set of 42 rules
##
## rule length distribution (lhs + rhs):sizes
## 2 3 4
## 12 27 3
##
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.000 2.000 3.000 2.786 3.000 4.000
##
## summary of quality measures:
## support confidence lift count
## Min. :0.003093 Min. :0.5032 Min. : 3.125 Min. : 59.00
## 1st Qu.:0.003683 1st Qu.:0.5944 1st Qu.: 6.307 1st Qu.: 70.25
## Median :0.004561 Median :0.7586 Median : 8.235 Median : 87.00
## Mean :0.006836 Mean :0.7404 Mean : 8.929 Mean :130.40
## 3rd Qu.:0.007496 3rd Qu.:0.8721 3rd Qu.: 9.016 3rd Qu.:143.00
## Max. :0.028570 Max. :1.0000 Max. :26.179 Max. :545.00
##
## mining info:
## data ntransactions support confidence
## TransFood 19076 0.003 0.5
Checking the generated rules
inspect(basket_rules)
## lhs rhs support confidence lift count
## [1] {Small.Pink.LemonadeFood} => {Chicken.Nugget.BasketFood} 0.003355001 0.5925926 16.034463 64
## [2] {Grilled.Chicken.SandwichFood} => {French.Fries.BasketFood} 0.003721954 0.6698113 6.862149 71
## [3] {FloatFood} => {Ice.Cream.ConeFood} 0.007024533 0.7089947 6.355631 134
## [4] {Side.of.CheeseFood} => {Cheese.ConeyFood} 0.004665548 0.6846154 25.912149 89
## [5] {Side.of.CheeseFood} => {Hot.DogFood} 0.006290627 0.9230769 21.605663 120
## [6] {BurgerFood} => {French.Fries.BasketFood} 0.004613126 0.6616541 6.778579 88
## [7] {SandwichFood} => {French.Fries.BasketFood} 0.007653596 0.6822430 6.989510 146
## [8] {Hot.Chocolate.Souvenir.RefillFood} => {Hot.Chocolate.SouvenirFood} 0.014992661 0.5596869 13.180972 286
## [9] {ToppingFood} => {Ice.Cream.ConeFood} 0.028569931 0.9981685 8.947868 545
## [10] {Add.CheeseFood} => {Soft.Pretzel..3_39Food} 0.019133990 0.6965649 7.601643 365
## [11] {Chicken.TendersFood} => {French.Fries.BasketFood} 0.017299224 0.7586207 7.771992 330
## [12] {CheeseburgerFood} => {French.Fries.BasketFood} 0.016879849 0.7931034 8.125264 322
## [13] {Cheese.ConeyFood,
## Side.of.CheeseFood} => {Hot.DogFood} 0.004351017 0.9325843 21.828193 83
## [14] {Hot.DogFood,
## Side.of.CheeseFood} => {Cheese.ConeyFood} 0.004351017 0.6916667 26.179034 83
## [15] {Bottled.WaterFood,
## ToppingFood} => {Ice.Cream.ConeFood} 0.004036486 1.0000000 8.964286 77
## [16] {Add.CheeseFood,
## Bottled.WaterFood} => {Soft.Pretzel..3_39Food} 0.003826798 0.8021978 8.754419 73
## [17] {CheeseburgerFood,
## Chicken.TendersFood} => {French.Fries.BasketFood} 0.003931642 0.9615385 9.850863 75
## [18] {Chicken.TendersFood,
## Souvenir.DrinkFood} => {French.Fries.BasketFood} 0.003197735 0.7922078 8.116088 61
## [19] {Chicken.TendersFood,
## Krazy.KritterFood} => {French.Fries.BasketFood} 0.005661564 0.9557522 9.791584 108
## [20] {Chicken.TendersFood,
## Slice.of.PeppFood} => {French.Fries.BasketFood} 0.003669532 0.9210526 9.436090 70
## [21] {Chicken.TendersFood,
## Small.DrinkFood} => {French.Fries.BasketFood} 0.004822814 0.8214286 8.415452 92
## [22] {Chicken.TendersFood,
## Medium.DrinkFood} => {French.Fries.BasketFood} 0.004141329 0.8144330 8.343783 79
## [23] {Bottled.WaterFood,
## Chicken.TendersFood} => {French.Fries.BasketFood} 0.003459845 0.7586207 7.771992 66
## [24] {Chicken.TendersFood,
## Slice.of.CheeseFood} => {French.Fries.BasketFood} 0.005399455 0.8728814 8.942580 103
## [25] {CheeseburgerFood,
## Souvenir.DrinkFood} => {French.Fries.BasketFood} 0.003250157 0.9117647 9.340936 62
## [26] {CheeseburgerFood,
## Krazy.KritterFood} => {French.Fries.BasketFood} 0.005451877 0.8813559 9.029402 104
## [27] {CheeseburgerFood,
## Slice.of.PeppFood} => {French.Fries.BasketFood} 0.003721954 0.8658537 8.870582 71
## [28] {CheeseburgerFood,
## Small.DrinkFood} => {French.Fries.BasketFood} 0.004141329 0.8315789 8.519441 79
## [29] {CheeseburgerFood,
## Medium.DrinkFood} => {French.Fries.BasketFood} 0.005189767 0.8761062 8.975619 99
## [30] {Bottled.WaterFood,
## CheeseburgerFood} => {French.Fries.BasketFood} 0.003092892 0.7662338 7.849987 59
## [31] {CheeseburgerFood,
## Slice.of.CheeseFood} => {French.Fries.BasketFood} 0.005242189 0.8695652 8.908607 100
## [32] {ChipsFood,
## Slice.of.PeppFood} => {Slice.of.CheeseFood} 0.008282659 0.5808824 3.607068 158
## [33] {CookieFood,
## Slice.of.PeppFood} => {Slice.of.CheeseFood} 0.004508283 0.5243902 3.256272 86
## [34] {Hot.DogFood,
## Krazy.KritterFood} => {French.Fries.BasketFood} 0.003669532 0.6140351 6.290727 70
## [35] {Ice.Cream.ConeFood,
## Slice.of.PeppFood} => {Slice.of.CheeseFood} 0.003407423 0.5200000 3.229010 65
## [36] {GatoradeFood,
## Slice.of.PeppFood} => {Slice.of.CheeseFood} 0.010117425 0.5830816 3.620724 193
## [37] {Slice.of.PeppFood,
## Souvenir.DrinkFood} => {Slice.of.CheeseFood} 0.008125393 0.5032468 3.124979 155
## [38] {Medium.DrinkFood,
## Slice.of.PeppFood} => {Slice.of.CheeseFood} 0.013629692 0.5273834 3.274858 260
## [39] {Bottled.WaterFood,
## Slice.of.PeppFood} => {Slice.of.CheeseFood} 0.010694066 0.5151515 3.198903 204
## [40] {Krazy.KritterFood,
## Medium.DrinkFood,
## Slice.of.PeppFood} => {Slice.of.CheeseFood} 0.003250157 0.5535714 3.437477 62
## [41] {Medium.DrinkFood,
## Slice.of.PeppFood,
## Small.DrinkFood} => {Slice.of.CheeseFood} 0.003145313 0.6000000 3.725781 60
## [42] {Medium.DrinkFood,
## Slice.of.CheeseFood,
## Small.DrinkFood} => {Slice.of.PeppFood} 0.003145313 0.5172414 4.191545 60
Basket rules of size greater than 3
inspect(subset(basket_rules, size(basket_rules)>3))
## lhs rhs support confidence lift count
## [1] {Krazy.KritterFood,
## Medium.DrinkFood,
## Slice.of.PeppFood} => {Slice.of.CheeseFood} 0.003250157 0.5535714 3.437477 62
## [2] {Medium.DrinkFood,
## Slice.of.PeppFood,
## Small.DrinkFood} => {Slice.of.CheeseFood} 0.003145313 0.6000000 3.725781 60
## [3] {Medium.DrinkFood,
## Slice.of.CheeseFood,
## Small.DrinkFood} => {Slice.of.PeppFood} 0.003145313 0.5172414 4.191545 60
Basket rules of size lift greater than 10
inspect(subset(basket_rules, lift>10))
## lhs rhs support confidence lift count
## [1] {Small.Pink.LemonadeFood} => {Chicken.Nugget.BasketFood} 0.003355001 0.5925926 16.03446 64
## [2] {Side.of.CheeseFood} => {Cheese.ConeyFood} 0.004665548 0.6846154 25.91215 89
## [3] {Side.of.CheeseFood} => {Hot.DogFood} 0.006290627 0.9230769 21.60566 120
## [4] {Hot.Chocolate.Souvenir.RefillFood} => {Hot.Chocolate.SouvenirFood} 0.014992661 0.5596869 13.18097 286
## [5] {Cheese.ConeyFood,
## Side.of.CheeseFood} => {Hot.DogFood} 0.004351017 0.9325843 21.82819 83
## [6] {Hot.DogFood,
## Side.of.CheeseFood} => {Cheese.ConeyFood} 0.004351017 0.6916667 26.17903 83
Basket rules containing french fries on rhs and lift greater than 8
French.Fries.BasketFood.rhs <- subset(basket_rules, subset = rhs %in% "French.Fries.BasketFood" & lift>8)
inspect(French.Fries.BasketFood.rhs)
## lhs rhs support confidence lift count
## [1] {CheeseburgerFood} => {French.Fries.BasketFood} 0.016879849 0.7931034 8.125264 322
## [2] {CheeseburgerFood,
## Chicken.TendersFood} => {French.Fries.BasketFood} 0.003931642 0.9615385 9.850863 75
## [3] {Chicken.TendersFood,
## Souvenir.DrinkFood} => {French.Fries.BasketFood} 0.003197735 0.7922078 8.116088 61
## [4] {Chicken.TendersFood,
## Krazy.KritterFood} => {French.Fries.BasketFood} 0.005661564 0.9557522 9.791584 108
## [5] {Chicken.TendersFood,
## Slice.of.PeppFood} => {French.Fries.BasketFood} 0.003669532 0.9210526 9.436090 70
## [6] {Chicken.TendersFood,
## Small.DrinkFood} => {French.Fries.BasketFood} 0.004822814 0.8214286 8.415452 92
## [7] {Chicken.TendersFood,
## Medium.DrinkFood} => {French.Fries.BasketFood} 0.004141329 0.8144330 8.343783 79
## [8] {Chicken.TendersFood,
## Slice.of.CheeseFood} => {French.Fries.BasketFood} 0.005399455 0.8728814 8.942580 103
## [9] {CheeseburgerFood,
## Souvenir.DrinkFood} => {French.Fries.BasketFood} 0.003250157 0.9117647 9.340936 62
## [10] {CheeseburgerFood,
## Krazy.KritterFood} => {French.Fries.BasketFood} 0.005451877 0.8813559 9.029402 104
## [11] {CheeseburgerFood,
## Slice.of.PeppFood} => {French.Fries.BasketFood} 0.003721954 0.8658537 8.870582 71
## [12] {CheeseburgerFood,
## Small.DrinkFood} => {French.Fries.BasketFood} 0.004141329 0.8315789 8.519441 79
## [13] {CheeseburgerFood,
## Medium.DrinkFood} => {French.Fries.BasketFood} 0.005189767 0.8761062 8.975619 99
## [14] {CheeseburgerFood,
## Slice.of.CheeseFood} => {French.Fries.BasketFood} 0.005242189 0.8695652 8.908607 100
Visualizing Association Rules
Plotting confidence vs support of all rules
plot(basket_rules)
Plot selected rules with their corresponding support and lift
plot(basket_rules, method="grouped")
Graph Plot of 10 rules with highest lift
plot(head(sort(basket_rules, by="lift"), 10), method = "graph")