Association rules using titanic data

YunShen

2/13/2018

The association rules

This presentation is using to demonstrate the association rules used in the shiny app First introducing some basic conveps of the assocation rules.
(have rule like {X} -> {Y})

Apriori

An example using Titanic raw data

##   Class  Sex   Age Survived
## 1   3rd Male Child       No
## 2   3rd Male Child       No
## 3   3rd Male Child       No
## 4   3rd Male Child       No
## 5   3rd Male Child       No
## 6   3rd Male Child       No

Generating all the rules

## Loading required package: Matrix
## 
## Attaching package: 'arules'
## The following objects are masked from 'package:base':
## 
##     abbreviate, write
## 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: 220 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[10 item(s), 2201 transaction(s)] done [0.00s].
## sorting and recoding items ... [9 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 4 done [0.00s].
## writing ... [27 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
##      lhs                rhs       support   confidence lift      count
## [1]               ----> Age=Adult 0.9504771 0.9504771  1.0000000 2092 
## [2]  Class=2nd    ----> Age=Adult 0.1185825 0.9157895  0.9635051  261 
## [3]  Class=1st    ----> Age=Adult 0.1449341 0.9815385  1.0326798  319 
## [4]  Sex=Female   ----> Age=Adult 0.1930940 0.9042553  0.9513700  425 
## [5]  Class=3rd    ----> Age=Adult 0.2848705 0.8881020  0.9343750  627 
## [6]  Survived=Yes ----> Age=Adult 0.2971377 0.9198312  0.9677574  654 
## [7]  Class=Crew   ----> Sex=Male  0.3916402 0.9740113  1.2384742  862 
## [8]  Class=Crew   ----> Age=Adult 0.4020900 1.0000000  1.0521033  885 
## [9]  Survived=No  ----> Sex=Male  0.6197183 0.9154362  1.1639949 1364 
## [10] Survived=No  ----> Age=Adult 0.6533394 0.9651007  1.0153856 1438

Visulizing all the rules

## Loading required package: grid
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout