Discretize age, income, and # children as factor
bank$age <- discretize(bank$age, method="frequency", breaks= 3, labels = c('young', 'middle-age', 'old'), order=TRUE)
bank$income <- discretize(bank$income, method="frequency", breaks = 5, labels = c('lowest-income', 'low-income', 'average-income',
'high-income', 'highest-income'), order=TRUE )
bank$children <- as.factor(bank$children)
str(bank)
## 'data.frame': 600 obs. of 11 variables:
## $ age : Ord.factor w/ 3 levels "young"<"middle-age"<..: 2 2 3 1 3 3 1 3 2 3 ...
## ..- attr(*, "discretized:breaks")= num [1:4] 18 35 49 67
## ..- attr(*, "discretized:method")= chr "frequency"
## $ sex : Factor w/ 2 levels "FEMALE","MALE": 1 2 1 1 1 1 2 2 1 2 ...
## $ region : Factor w/ 4 levels "INNER_CITY","RURAL",..: 1 4 1 4 2 4 2 4 3 4 ...
## $ income : Ord.factor w/ 5 levels "lowest-income"<..: 2 4 2 2 5 4 1 3 3 3 ...
## ..- attr(*, "discretized:breaks")= num [1:6] 5014 15838 22162 28480 38448 ...
## ..- attr(*, "discretized:method")= chr "frequency"
## $ married : Factor w/ 2 levels "NO","YES": 1 2 2 2 2 2 1 2 2 2 ...
## $ children : Factor w/ 4 levels "0","1","2","3": 2 4 1 4 1 3 1 1 3 3 ...
## $ car : Factor w/ 2 levels "NO","YES": 1 2 2 1 1 1 1 2 2 2 ...
## $ save_act : Factor w/ 2 levels "NO","YES": 1 1 2 1 2 2 1 2 1 2 ...
## $ current_act: Factor w/ 2 levels "NO","YES": 1 2 2 2 1 2 2 2 1 2 ...
## $ mortgage : Factor w/ 2 levels "NO","YES": 1 2 1 1 1 1 1 1 1 1 ...
## $ pep : Factor w/ 2 levels "NO","YES": 2 1 1 1 1 2 2 1 1 1 ...
Association rule discovery, 20-30 strong rules with high lift and confidence
Rule that is likely to result in a RHS “FEMALE”
FEMALE_rules <- apriori(bank, parameter=list(supp=.1, conf=.5),
appearance=list(default="lhs", rhs="sex=FEMALE"),
control=list(verbose=F))
FEMALE_rules
## set of 104 rules
FEMALE_rules <- sort(FEMALE_rules, by="lift", decreasing=TRUE)
inspect(FEMALE_rules[1:20])
## lhs rhs support confidence coverage lift count
## [1] {married=YES,
## children=0,
## mortgage=NO,
## pep=NO} => {sex=FEMALE} 0.1050000 0.6057692 0.1733333 1.211538 63
## [2] {married=YES,
## children=0,
## mortgage=NO} => {sex=FEMALE} 0.1166667 0.6034483 0.1933333 1.206897 70
## [3] {children=0,
## mortgage=NO,
## pep=NO} => {sex=FEMALE} 0.1066667 0.5981308 0.1783333 1.196262 64
## [4] {car=NO,
## mortgage=NO,
## pep=NO} => {sex=FEMALE} 0.1066667 0.5925926 0.1800000 1.185185 64
## [5] {age=old,
## current_act=YES,
## mortgage=NO} => {sex=FEMALE} 0.1083333 0.5909091 0.1833333 1.181818 65
## [6] {children=0,
## current_act=YES,
## mortgage=NO} => {sex=FEMALE} 0.1216667 0.5840000 0.2083333 1.168000 73
## [7] {region=TOWN,
## married=YES} => {sex=FEMALE} 0.1116667 0.5826087 0.1916667 1.165217 67
## [8] {car=NO,
## save_act=YES,
## mortgage=NO} => {sex=FEMALE} 0.1250000 0.5813953 0.2150000 1.162791 75
## [9] {married=YES,
## car=NO,
## current_act=YES,
## mortgage=NO} => {sex=FEMALE} 0.1000000 0.5769231 0.1733333 1.153846 60
## [10] {age=old,
## current_act=YES} => {sex=FEMALE} 0.1516667 0.5759494 0.2633333 1.151899 91
## [11] {age=old,
## mortgage=NO} => {sex=FEMALE} 0.1333333 0.5755396 0.2316667 1.151079 80
## [12] {married=YES,
## car=NO,
## mortgage=NO} => {sex=FEMALE} 0.1266667 0.5714286 0.2216667 1.142857 76
## [13] {married=YES,
## children=0,
## current_act=YES,
## pep=NO} => {sex=FEMALE} 0.1000000 0.5714286 0.1750000 1.142857 60
## [14] {age=old} => {sex=FEMALE} 0.1983333 0.5666667 0.3500000 1.133333 119
## [15] {age=old,
## car=YES} => {sex=FEMALE} 0.1066667 0.5663717 0.1883333 1.132743 64
## [16] {car=NO,
## mortgage=NO} => {sex=FEMALE} 0.1833333 0.5583756 0.3283333 1.116751 110
## [17] {region=INNER_CITY,
## current_act=YES,
## pep=NO} => {sex=FEMALE} 0.1066667 0.5565217 0.1916667 1.113043 64
## [18] {region=TOWN,
## mortgage=NO} => {sex=FEMALE} 0.1000000 0.5555556 0.1800000 1.111111 60
## [19] {children=0,
## mortgage=NO} => {sex=FEMALE} 0.1516667 0.5548780 0.2733333 1.109756 91
## [20] {save_act=NO,
## mortgage=NO} => {sex=FEMALE} 0.1116667 0.5537190 0.2016667 1.107438 67
inspectDT(FEMALE_rules[1:20])
Rule that is likely to result in a RHS “MALE”
MALE_rules <- apriori(bank, parameter=list(supp=.1, conf=.5),
appearance=list(default="lhs", rhs="sex=MALE"),
control=list(verbose=F))
MALE_rules
## set of 59 rules
MALE_rules <- sort(MALE_rules, by="lift", decreasing=TRUE)
inspect(MALE_rules[1:20])
## lhs rhs support confidence
## [1] {car=NO,mortgage=YES} => {sex=MALE} 0.1066667 0.5981308
## [2] {married=YES,mortgage=YES} => {sex=MALE} 0.1300000 0.5777778
## [3] {region=INNER_CITY,pep=YES} => {sex=MALE} 0.1150000 0.5609756
## [4] {married=YES,pep=YES} => {sex=MALE} 0.1433333 0.5584416
## [5] {age=middle-age,current_act=YES} => {sex=MALE} 0.1333333 0.5555556
## [6] {car=YES,save_act=YES,mortgage=NO} => {sex=MALE} 0.1300000 0.5531915
## [7] {age=middle-age} => {sex=MALE} 0.1783333 0.5487179
## [8] {region=INNER_CITY,car=NO} => {sex=MALE} 0.1266667 0.5467626
## [9] {mortgage=YES} => {sex=MALE} 0.1900000 0.5454545
## [10] {car=YES,pep=YES} => {sex=MALE} 0.1250000 0.5434783
## [11] {married=YES,current_act=YES,pep=YES} => {sex=MALE} 0.1050000 0.5431034
## [12] {current_act=YES,mortgage=YES} => {sex=MALE} 0.1383333 0.5389610
## [13] {age=middle-age,save_act=YES} => {sex=MALE} 0.1166667 0.5384615
## [14] {age=middle-age,married=YES} => {sex=MALE} 0.1166667 0.5343511
## [15] {save_act=YES,pep=YES} => {sex=MALE} 0.1583333 0.5307263
## [16] {mortgage=YES,pep=NO} => {sex=MALE} 0.1033333 0.5299145
## [17] {region=INNER_CITY,married=YES} => {sex=MALE} 0.1566667 0.5280899
## [18] {save_act=YES,mortgage=YES} => {sex=MALE} 0.1266667 0.5277778
## [19] {pep=YES} => {sex=MALE} 0.2400000 0.5255474
## [20] {income=lowest-income} => {sex=MALE} 0.1050000 0.5250000
## coverage lift count
## [1] 0.1783333 1.196262 64
## [2] 0.2250000 1.155556 78
## [3] 0.2050000 1.121951 69
## [4] 0.2566667 1.116883 86
## [5] 0.2400000 1.111111 80
## [6] 0.2350000 1.106383 78
## [7] 0.3250000 1.097436 107
## [8] 0.2316667 1.093525 76
## [9] 0.3483333 1.090909 114
## [10] 0.2300000 1.086957 75
## [11] 0.1933333 1.086207 63
## [12] 0.2566667 1.077922 83
## [13] 0.2166667 1.076923 70
## [14] 0.2183333 1.068702 70
## [15] 0.2983333 1.061453 95
## [16] 0.1950000 1.059829 62
## [17] 0.2966667 1.056180 94
## [18] 0.2400000 1.055556 76
## [19] 0.4566667 1.051095 144
## [20] 0.2000000 1.050000 63
inspectDT(MALE_rules[1:20])
Income prediction rules
Rule that is likely to result in a RHS “income=lowest-income”
Lowest_Income_rules <- apriori(bank, parameter=list(supp=.05, conf=.25),
appearance=list(default="lhs", rhs="income=lowest-income"),
control=list(verbose=F))
Lowest_Income_rules
## set of 112 rules
Lowest_Income_rules<- sort(Lowest_Income_rules, by="lift", decreasing=TRUE)
inspect(Lowest_Income_rules[1:15])
## lhs rhs support confidence coverage lift count
## [1] {age=young,
## region=INNER_CITY,
## married=YES,
## pep=NO} => {income=lowest-income} 0.05333333 0.7619048 0.07000000 3.809524 32
## [2] {age=young,
## region=INNER_CITY,
## current_act=YES,
## pep=NO} => {income=lowest-income} 0.05833333 0.7291667 0.08000000 3.645833 35
## [3] {age=young,
## region=INNER_CITY,
## pep=NO} => {income=lowest-income} 0.07000000 0.7118644 0.09833333 3.559322 42
## [4] {age=young,
## car=YES,
## current_act=YES,
## pep=NO} => {income=lowest-income} 0.05166667 0.6888889 0.07500000 3.444444 31
## [5] {age=young,
## save_act=YES,
## current_act=YES,
## pep=NO} => {income=lowest-income} 0.07166667 0.6718750 0.10666667 3.359375 43
## [6] {age=young,
## region=INNER_CITY,
## current_act=YES,
## mortgage=NO} => {income=lowest-income} 0.05000000 0.6666667 0.07500000 3.333333 30
## [7] {age=young,
## sex=FEMALE,
## current_act=YES,
## pep=NO} => {income=lowest-income} 0.05500000 0.6600000 0.08333333 3.300000 33
## [8] {age=young,
## current_act=YES,
## pep=NO} => {income=lowest-income} 0.10333333 0.6526316 0.15833333 3.263158 62
## [9] {age=young,
## region=INNER_CITY,
## save_act=YES,
## current_act=YES} => {income=lowest-income} 0.05000000 0.6521739 0.07666667 3.260870 30
## [10] {age=young,
## married=YES,
## car=NO,
## pep=NO} => {income=lowest-income} 0.05000000 0.6521739 0.07666667 3.260870 30
## [11] {age=young,
## sex=MALE,
## pep=NO} => {income=lowest-income} 0.06500000 0.6393443 0.10166667 3.196721 39
## [12] {age=young,
## car=NO,
## pep=NO} => {income=lowest-income} 0.07000000 0.6363636 0.11000000 3.181818 42
## [13] {age=young,
## married=YES,
## current_act=YES,
## pep=NO} => {income=lowest-income} 0.07000000 0.6363636 0.11000000 3.181818 42
## [14] {age=young,
## save_act=YES,
## pep=NO} => {income=lowest-income} 0.08666667 0.6341463 0.13666667 3.170732 52
## [15] {age=young,
## married=YES,
## current_act=YES,
## mortgage=NO,
## pep=NO} => {income=lowest-income} 0.05166667 0.6326531 0.08166667 3.163265 31
inspectDT(Lowest_Income_rules[1:15])
Rule that is likely to result in a RHS “income=low-income”
Low_Income_rules <- apriori(bank, parameter=list(supp=.05, conf=.25),
appearance=list(default="lhs", rhs="income=low-income"),
control=list(verbose=F))
Low_Income_rules
## set of 15 rules
Low_Income_rules<- sort(Low_Income_rules, by="lift", decreasing=TRUE)
inspect(Low_Income_rules[1:15])
## lhs rhs support confidence coverage lift count
## [1] {age=young,
## married=YES} => {income=low-income} 0.06666667 0.3125000 0.2133333 1.562500 40
## [2] {age=young,
## mortgage=NO} => {income=low-income} 0.06166667 0.2960000 0.2083333 1.480000 37
## [3] {married=YES,
## car=NO,
## current_act=YES,
## mortgage=NO} => {income=low-income} 0.05000000 0.2884615 0.1733333 1.442308 30
## [4] {region=TOWN,
## mortgage=NO} => {income=low-income} 0.05166667 0.2870370 0.1800000 1.435185 31
## [5] {age=young} => {income=low-income} 0.09166667 0.2820513 0.3250000 1.410256 55
## [6] {age=young,
## car=NO} => {income=low-income} 0.05000000 0.2803738 0.1783333 1.401869 30
## [7] {married=YES,
## car=NO,
## mortgage=NO} => {income=low-income} 0.06000000 0.2706767 0.2216667 1.353383 36
## [8] {age=young,
## current_act=YES} => {income=low-income} 0.06833333 0.2679739 0.2550000 1.339869 41
## [9] {age=middle-age,
## married=YES} => {income=low-income} 0.05833333 0.2671756 0.2183333 1.335878 35
## [10] {married=YES,
## car=NO,
## current_act=YES} => {income=low-income} 0.06666667 0.2649007 0.2516667 1.324503 40
## [11] {married=YES,
## save_act=NO} => {income=low-income} 0.05166667 0.2605042 0.1983333 1.302521 31
## [12] {age=young,
## save_act=YES} => {income=low-income} 0.05166667 0.2605042 0.1983333 1.302521 31
## [13] {married=YES,
## car=NO} => {income=low-income} 0.08500000 0.2524752 0.3366667 1.262376 51
## [14] {age=middle-age,
## mortgage=NO} => {income=low-income} 0.05333333 0.2519685 0.2116667 1.259843 32
## [15] {save_act=NO,
## current_act=YES} => {income=low-income} 0.05666667 0.2500000 0.2266667 1.250000 34
inspectDT(Low_Income_rules[1:15])
Rule that is likely to result in a RHS “income=average-income”
avg_Income_rules <- apriori(bank, parameter=list(supp=.05, conf=.25),
appearance=list(default="lhs", rhs="income=average-income"),
control=list(verbose=F))
avg_Income_rules
## set of 15 rules
avg_Income_rules<- sort(avg_Income_rules, by="lift", decreasing=TRUE)
inspect(avg_Income_rules[1:15])
## lhs rhs support confidence coverage lift count
## [1] {children=0,
## save_act=NO} => {income=average-income} 0.05000000 0.3370787 0.1483333 1.685393 30
## [2] {car=NO,
## save_act=NO} => {income=average-income} 0.05166667 0.3131313 0.1650000 1.565657 31
## [3] {age=middle-age,
## children=0} => {income=average-income} 0.05000000 0.3061224 0.1633333 1.530612 30
## [4] {age=middle-age,
## pep=NO} => {income=average-income} 0.05500000 0.3055556 0.1800000 1.527778 33
## [5] {age=middle-age,
## sex=MALE} => {income=average-income} 0.05166667 0.2897196 0.1783333 1.448598 31
## [6] {married=YES,
## save_act=NO} => {income=average-income} 0.05666667 0.2857143 0.1983333 1.428571 34
## [7] {save_act=NO} => {income=average-income} 0.08833333 0.2849462 0.3100000 1.424731 53
## [8] {age=middle-age,
## married=YES} => {income=average-income} 0.05833333 0.2671756 0.2183333 1.335878 35
## [9] {children=0,
## car=YES} => {income=average-income} 0.05500000 0.2661290 0.2066667 1.330645 33
## [10] {save_act=NO,
## mortgage=NO} => {income=average-income} 0.05333333 0.2644628 0.2016667 1.322314 32
## [11] {age=middle-age} => {income=average-income} 0.08500000 0.2615385 0.3250000 1.307692 51
## [12] {save_act=NO,
## current_act=YES} => {income=average-income} 0.05833333 0.2573529 0.2266667 1.286765 35
## [13] {age=middle-age,
## current_act=YES} => {income=average-income} 0.06166667 0.2569444 0.2400000 1.284722 37
## [14] {age=middle-age,
## mortgage=NO} => {income=average-income} 0.05333333 0.2519685 0.2116667 1.259843 32
## [15] {sex=FEMALE,
## children=0} => {income=average-income} 0.05500000 0.2500000 0.2200000 1.250000 33
inspectDT(avg_Income_rules[1:15])
Rule that is likely to result in a RHS “income=high-income”
high_Income_rules <- apriori(bank, parameter=list(supp=.05, conf=.25),
appearance=list(default="lhs", rhs="income=high-income"),
control=list(verbose=F))
high_Income_rules
## set of 27 rules
high_Income_rules<- sort(high_Income_rules, by="lift", decreasing=TRUE)
inspect(high_Income_rules[1:15])
## lhs rhs support confidence coverage lift count
## [1] {age=middle-age,
## save_act=YES,
## current_act=YES} => {income=high-income} 0.06500000 0.3861386 0.1683333 1.930693 39
## [2] {age=middle-age,
## save_act=YES} => {income=high-income} 0.08166667 0.3769231 0.2166667 1.884615 49
## [3] {age=middle-age,
## save_act=YES,
## mortgage=NO} => {income=high-income} 0.05000000 0.3571429 0.1400000 1.785714 30
## [4] {age=middle-age,
## pep=YES} => {income=high-income} 0.05000000 0.3448276 0.1450000 1.724138 30
## [5] {age=middle-age,
## current_act=YES} => {income=high-income} 0.08000000 0.3333333 0.2400000 1.666667 48
## [6] {age=middle-age,
## car=YES} => {income=high-income} 0.05000000 0.3157895 0.1583333 1.578947 30
## [7] {age=old,
## car=YES} => {income=high-income} 0.05833333 0.3097345 0.1883333 1.548673 35
## [8] {age=middle-age,
## sex=MALE} => {income=high-income} 0.05500000 0.3084112 0.1783333 1.542056 33
## [9] {age=middle-age} => {income=high-income} 0.10000000 0.3076923 0.3250000 1.538462 60
## [10] {age=middle-age,
## car=NO} => {income=high-income} 0.05000000 0.3000000 0.1666667 1.500000 30
## [11] {sex=FEMALE,
## car=YES,
## current_act=YES} => {income=high-income} 0.05333333 0.2909091 0.1833333 1.454545 32
## [12] {sex=FEMALE,
## car=YES} => {income=high-income} 0.06833333 0.2789116 0.2450000 1.394558 41
## [13] {age=middle-age,
## pep=NO} => {income=high-income} 0.05000000 0.2777778 0.1800000 1.388889 30
## [14] {age=old,
## pep=YES} => {income=high-income} 0.05333333 0.2758621 0.1933333 1.379310 32
## [15] {age=middle-age,
## mortgage=NO} => {income=high-income} 0.05833333 0.2755906 0.2116667 1.377953 35
inspectDT(high_Income_rules[1:15])
Rule that is likely to result in a RHS “income=highest-income”
highest_Income_rules <- apriori(bank, parameter=list(supp=.05, conf=.25),
appearance=list(default="lhs", rhs="income=highest-income"),
control=list(verbose=F))
highest_Income_rules
## set of 157 rules
highest_Income_rules<- sort(highest_Income_rules, by="lift", decreasing=TRUE)
inspect(highest_Income_rules[1:15])
## lhs rhs support confidence coverage lift count
## [1] {age=old,
## children=0,
## save_act=YES,
## current_act=YES} => {income=highest-income} 0.05833333 0.7291667 0.08000000 3.645833 35
## [2] {age=old,
## married=YES,
## children=0,
## save_act=YES} => {income=highest-income} 0.05166667 0.7045455 0.07333333 3.522727 31
## [3] {age=old,
## save_act=YES,
## mortgage=NO,
## pep=YES} => {income=highest-income} 0.07333333 0.6984127 0.10500000 3.492063 44
## [4] {age=old,
## save_act=YES,
## current_act=YES,
## mortgage=NO,
## pep=YES} => {income=highest-income} 0.05833333 0.6862745 0.08500000 3.431373 35
## [5] {age=old,
## car=NO,
## save_act=YES,
## current_act=YES} => {income=highest-income} 0.06500000 0.6842105 0.09500000 3.421053 39
## [6] {age=old,
## sex=MALE,
## save_act=YES,
## pep=YES} => {income=highest-income} 0.05000000 0.6818182 0.07333333 3.409091 30
## [7] {age=old,
## save_act=YES,
## current_act=YES,
## pep=YES} => {income=highest-income} 0.07500000 0.6818182 0.11000000 3.409091 45
## [8] {age=old,
## children=0,
## save_act=YES,
## pep=NO} => {income=highest-income} 0.05333333 0.6808511 0.07833333 3.404255 32
## [9] {age=old,
## car=NO,
## save_act=YES,
## mortgage=NO} => {income=highest-income} 0.05666667 0.6800000 0.08333333 3.400000 34
## [10] {age=old,
## children=0,
## save_act=YES} => {income=highest-income} 0.07000000 0.6774194 0.10333333 3.387097 42
## [11] {age=old,
## save_act=YES,
## pep=YES} => {income=highest-income} 0.09833333 0.6704545 0.14666667 3.352273 59
## [12] {age=old,
## married=YES,
## save_act=YES,
## pep=YES} => {income=highest-income} 0.05666667 0.6666667 0.08500000 3.333333 34
## [13] {age=old,
## married=YES,
## save_act=YES,
## current_act=YES} => {income=highest-income} 0.08666667 0.6666667 0.13000000 3.333333 52
## [14] {age=old,
## sex=FEMALE,
## save_act=YES,
## current_act=YES,
## mortgage=NO} => {income=highest-income} 0.05000000 0.6666667 0.07500000 3.333333 30
## [15] {age=old,
## married=YES,
## save_act=YES,
## current_act=YES,
## mortgage=NO} => {income=highest-income} 0.05500000 0.6470588 0.08500000 3.235294 33
inspectDT(highest_Income_rules[1:15])
Plot rules to copmare
plot(Lowest_Income_rules, jitter=0)

plot(Low_Income_rules, jitter=0)

plot(avg_Income_rules, jitter=0)

plot(high_Income_rules, jitter=0)

plot(highest_Income_rules,jitter=0)

A customer in the “Old Age” bracket is likely to…
old_rules <- apriori (data=bank, parameter=list (supp=0.001,conf = 0.15,minlen=2),
appearance = list(default="rhs",lhs="age=old"), control = list (verbose=F))
old_rules <- sort (old_rules, by="lift", decreasing=TRUE)
inspectDT((old_rules))
A customer in the “middle Age” bracket is likely to…
middle_age_rules <- apriori (data=bank, parameter=list (supp=0.001,conf = 0.15,minlen=2),
appearance = list(default="rhs",lhs="age=middle-age"), control = list (verbose=F))
middle_age_rules <- sort (middle_age_rules, by="lift", decreasing=TRUE)
inspectDT((middle_age_rules))
A customer in the “young Age” bracket is likely to…
young_age_rules <- apriori (data=bank, parameter=list (supp=0.001,conf = 0.15,minlen=2),
appearance = list(default="rhs",lhs="age=young"), control = list (verbose=F))
young_age_rules <- sort (young_age_rules, by="lift", decreasing=TRUE)
inspectDT((young_age_rules))
Find trends in PEP holders
PEP_Yes_rules <- apriori (data=bank, parameter=list (supp=.05, conf = 0.5, minlen=4, maxlen=6),
appearance = list(default="lhs",rhs=c("pep=YES")), control = list (verbose=F))
PEP_Yes_rules
## set of 168 rules
inspectDT((PEP_Yes_rules))
avg_lift <- mean(PEP_Yes_rules@quality$lift)
above_avg_PEP_Rules <- PEP_Yes_rules[which(PEP_Yes_rules@quality$lift>avg_lift)]
above_avg_PEP_Rules
## set of 75 rules
avg_confidence <- mean(above_avg_PEP_Rules@quality$confidence)
avg_support <- mean(above_avg_PEP_Rules@quality$support)
above_avg_PEP_Rules <- above_avg_PEP_Rules[which(above_avg_PEP_Rules@quality$confidence>avg_confidence)]
above_avg_PEP_Rules
## set of 45 rules
above_avg_PEP_Rules <- above_avg_PEP_Rules[which(above_avg_PEP_Rules@quality$support>avg_support)]
above_avg_PEP_Rules <- sort(above_avg_PEP_Rules, by="lift", decreasing = TRUE)
inspectDT((above_avg_PEP_Rules))
plot(above_avg_PEP_Rules, engine = "ggplot2", main = NULL, jitter=0) +
scale_color_gradient2(low = "red", mid="yellow", high = "blue",
midpoint = mean(above_avg_PEP_Rules@quality$lift), limits = c(min(above_avg_PEP_Rules@quality$lift),max(above_avg_PEP_Rules@quality$lift))) +
labs(x = "Supp.", y = "Conf.", color = "Lift")
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.

Again_Yes_rules <- apriori (data=bank, parameter=list (supp=.05, conf = 0.5, maxlen=2),
appearance = list(default="lhs",rhs=c("pep=YES")), control = list (verbose=F))
inspectDT(Again_Yes_rules)
bank$income
## [1] low-income high-income low-income low-income highest-income
## [6] high-income lowest-income average-income average-income average-income
## [11] highest-income average-income lowest-income highest-income low-income
## [16] average-income low-income highest-income average-income average-income
## [21] highest-income low-income high-income lowest-income lowest-income
## [26] highest-income low-income low-income high-income average-income
## [31] average-income low-income average-income high-income high-income
## [36] low-income lowest-income lowest-income low-income average-income
## [41] average-income average-income highest-income average-income lowest-income
## [46] highest-income lowest-income lowest-income highest-income low-income
## [51] lowest-income average-income low-income high-income highest-income
## [56] highest-income average-income average-income lowest-income average-income
## [61] average-income high-income average-income lowest-income lowest-income
## [66] low-income lowest-income high-income low-income lowest-income
## [71] lowest-income lowest-income high-income average-income highest-income
## [76] high-income average-income highest-income lowest-income high-income
## [81] low-income average-income lowest-income low-income average-income
## [86] high-income lowest-income average-income low-income high-income
## [91] average-income average-income high-income highest-income highest-income
## [96] lowest-income lowest-income high-income lowest-income lowest-income
## [101] average-income lowest-income lowest-income high-income high-income
## [106] high-income highest-income lowest-income lowest-income average-income
## [111] high-income average-income high-income high-income highest-income
## [116] highest-income low-income lowest-income low-income highest-income
## [121] high-income highest-income low-income high-income highest-income
## [126] highest-income average-income highest-income lowest-income low-income
## [131] average-income highest-income low-income high-income highest-income
## [136] high-income lowest-income highest-income highest-income highest-income
## [141] high-income average-income low-income highest-income low-income
## [146] highest-income low-income low-income average-income average-income
## [151] average-income high-income highest-income average-income average-income
## [156] lowest-income average-income low-income low-income lowest-income
## [161] low-income lowest-income low-income lowest-income average-income
## [166] average-income lowest-income lowest-income average-income high-income
## [171] highest-income low-income average-income average-income highest-income
## [176] highest-income high-income high-income lowest-income high-income
## [181] low-income highest-income high-income low-income high-income
## [186] high-income low-income high-income high-income low-income
## [191] highest-income lowest-income highest-income low-income high-income
## [196] low-income low-income highest-income lowest-income low-income
## [201] average-income highest-income low-income low-income lowest-income
## [206] lowest-income highest-income lowest-income highest-income low-income
## [211] average-income high-income lowest-income lowest-income lowest-income
## [216] low-income lowest-income high-income high-income high-income
## [221] average-income highest-income highest-income highest-income highest-income
## [226] average-income highest-income average-income average-income lowest-income
## [231] high-income high-income lowest-income high-income highest-income
## [236] low-income highest-income low-income low-income lowest-income
## [241] lowest-income highest-income high-income low-income average-income
## [246] high-income lowest-income low-income low-income low-income
## [251] highest-income high-income lowest-income low-income lowest-income
## [256] average-income average-income average-income low-income lowest-income
## [261] low-income high-income low-income highest-income low-income
## [266] low-income high-income high-income high-income low-income
## [271] highest-income highest-income lowest-income average-income average-income
## [276] lowest-income high-income average-income average-income high-income
## [281] average-income lowest-income highest-income highest-income lowest-income
## [286] lowest-income average-income average-income lowest-income high-income
## [291] lowest-income highest-income highest-income low-income average-income
## [296] high-income average-income lowest-income low-income lowest-income
## [301] lowest-income lowest-income high-income highest-income highest-income
## [306] lowest-income highest-income average-income average-income lowest-income
## [311] high-income high-income high-income low-income low-income
## [316] highest-income low-income high-income average-income low-income
## [321] high-income average-income lowest-income average-income high-income
## [326] lowest-income high-income low-income highest-income low-income
## [331] highest-income lowest-income high-income low-income low-income
## [336] average-income average-income high-income high-income low-income
## [341] high-income highest-income highest-income low-income average-income
## [346] highest-income highest-income highest-income high-income average-income
## [351] high-income average-income average-income highest-income high-income
## [356] highest-income average-income lowest-income high-income average-income
## [361] highest-income low-income high-income lowest-income highest-income
## [366] low-income high-income highest-income lowest-income high-income
## [371] highest-income highest-income lowest-income average-income highest-income
## [376] low-income high-income average-income low-income lowest-income
## [381] average-income high-income lowest-income high-income average-income
## [386] high-income lowest-income high-income lowest-income low-income
## [391] highest-income average-income high-income low-income average-income
## [396] average-income average-income high-income highest-income high-income
## [401] low-income low-income highest-income low-income lowest-income
## [406] high-income highest-income average-income low-income lowest-income
## [411] low-income lowest-income highest-income low-income highest-income
## [416] low-income lowest-income average-income average-income low-income
## [421] highest-income highest-income lowest-income highest-income low-income
## [426] high-income high-income high-income low-income average-income
## [431] high-income highest-income low-income average-income average-income
## [436] lowest-income low-income high-income lowest-income lowest-income
## [441] high-income highest-income high-income high-income lowest-income
## [446] high-income highest-income high-income highest-income high-income
## [451] high-income highest-income average-income highest-income low-income
## [456] lowest-income lowest-income highest-income lowest-income highest-income
## [461] average-income average-income low-income lowest-income low-income
## [466] average-income low-income lowest-income lowest-income high-income
## [471] highest-income average-income low-income average-income average-income
## [476] lowest-income average-income average-income average-income highest-income
## [481] lowest-income highest-income high-income low-income low-income
## [486] highest-income low-income low-income lowest-income low-income
## [491] high-income low-income average-income highest-income highest-income
## [496] highest-income highest-income highest-income highest-income low-income
## [501] average-income high-income average-income lowest-income highest-income
## [506] high-income average-income lowest-income highest-income lowest-income
## [511] lowest-income low-income highest-income lowest-income high-income
## [516] low-income low-income high-income low-income high-income
## [521] lowest-income low-income lowest-income low-income low-income
## [526] low-income lowest-income lowest-income average-income highest-income
## [531] highest-income average-income high-income high-income lowest-income
## [536] lowest-income high-income highest-income highest-income lowest-income
## [541] low-income high-income lowest-income highest-income low-income
## [546] high-income lowest-income lowest-income low-income highest-income
## [551] lowest-income high-income highest-income highest-income high-income
## [556] lowest-income low-income average-income high-income average-income
## [561] low-income average-income highest-income average-income average-income
## [566] average-income average-income low-income high-income low-income
## [571] high-income high-income average-income average-income average-income
## [576] high-income low-income highest-income lowest-income average-income
## [581] highest-income lowest-income low-income high-income average-income
## [586] lowest-income low-income high-income highest-income lowest-income
## [591] average-income high-income low-income highest-income high-income
## [596] highest-income lowest-income low-income lowest-income average-income
## attr(,"discretized:breaks")
## [1] 5014.21 15838.38 22162.30 28479.98 38448.02 63130.10
## attr(,"discretized:method")
## [1] frequency
## 5 Levels: lowest-income < low-income < average-income < ... < highest-income