I try to inspect basket rules from my basket data which looks like ;
df <- structure(list(Basket = c("4", "5", "9", "10", "22", "25,26,27",
"20", "9,15", "45", "7,2", "46", "48", "24,45,12,53", "54,10,30",
"56", "58", "60,29", "72", "8", "73", "59", "75,12", "14,23",
"69,11", "77", "80", "81,82,57,69", "83", "88,57,5", "64,36",
"13", "22,49", "47,43", "8", "40", "53", "37,22,20", "23", "9",
"47", "47", "69", "93,94", "95,59,77", "96", "3", "13", "20",
"23", "1,104,2", "12", "7", "47", "17", "32", "104,12,26", "83,43",
"14", "36,105,109,110", "7", "3,113", "64,115", "47", "80", "51,110,118",
"20,14,55", "110,113", "23", "13", "31,52,12,58", "128", "10,36",
"97,60,3,11", "64,70,38,14", "130,12,36", "132", "134,38,18",
"142,11", "145,69,77,135,126", "103,1", "65", "79", "1", "119",
"123,12", "12,83", "60,11,81", "115,62", "29", "20,151,49", "64,38",
"58,7,28,2", "36,3,58", "81,20", "45", "48", "10", "103", "155,133",
"7,59", "31,103,3,102,13,65,16,29", "11", "64,156", "5,73,157,13,30,14,116",
"65,3", "23,24", "63,126,115,35,64,158,30,38", "46", "5,70,77,52,97,36",
"11,70,88", "77", "110,131,46,12,36", "126", "48", "10", "139,126,78,110,23",
"59,160,120", "45", "57,22,161", "45", "30", "110", "5", "1",
"97,3", "11,22", "3", "151", "2", "33", "92,160,46,11,112,24,77",
"14,47", "60,70", "46,11,8", "156", "152,36", "95", "91", "36",
"11,131,48,18,8,129", "14,61", "95,59", "114", "103,102,175",
"103,11", "110", "59", "34", "110", "112", "25", "30,99,43,49",
"180", "47", "181", "10", "77,182,12", "36", "155,73,105", "11,20",
"20", "12", "11", "12", "1,2", "6,7", "8", "7,11,2,12,13", "14,15",
"16,7,3,17", "28,29", "20", "34", "35,23", "36,10", "37,14,5",
"38,14,39", "36,40,41", "42,43", "44,2", "14", "35,47", "49",
"51,52", "55", "57,11,22", "3", "68,29", "69", "11", "29", "58,45,3",
"20", "69", "5", "25,68", "63", "50", "5,79", "47", "29", "20",
"29", "45,91", "8", "42,3,61", "59", "23", "30", "65,97", "98",
"100,63,101,70", "13", "13,2", "14", "102,70,39,103", "7", "68,105,106",
"14,43,47", "3", "47", "87", "22", "47", "25,105", "88,72,107,14",
"108", "92,103", "5", "14,46,20", "22", "59", "31", "114", "47,11,29",
"12,6,116", "14", "60", "105", "10,59", "78", "21,87", "7,5,103,43",
"51,12", "58", "58,16,11", "135,11", "137,74,44,2,138,139", "77",
"141", "34,47", "46,10,143,97", "144", "8,22", "14,5", "29,95,146,2,116,1",
"20", "12,108", "49", "59,95,148", "12", "14", "59", "105", "29",
"5", "17,112,103,152,72,32,131,10", "12", "11,69", "153,154",
"8,135,3,46", "103", "3,17,59", "2", "42,49", "11,23", "60",
"56", "39", "58,66,31", "56,36,119", "39,36,2", "159", "123,11",
"126", "162", "11,23,163,1,164,165,157,144", "110", "30,166,4,18",
"110", "68", "13", "88", "88,5", "168,102", "110", "169,11",
"170", "18,23,14", "95,23,12", "23", "35,59,135,95", "148,103,146",
"103", "29", "36,61", "23", "172,11", "31,78", "29", "110", "102",
"8", "81", "14", "64,174,58,93,115,17", "101,78", "47", "49",
"96,46,59", "17", "11,119", "5,12,136", "56,176", "93,110,148,12",
"5,13", "69", "22", "24,76,101,98,123,163,178", "81,41", "58",
"37", "30", "17,179,116,43,150,10", "40", "92", "162", "103",
"45", "35", "29", "13,45,144", "72,35", "17,45,66,3,61,58", "3",
"18,19,20,21,22,23", "24", "30", "20,31", "32,33", "22,4", "34",
"29", "1", "50", "36", "14", "59", "61,62", "36,63,54,64", "65,66,3,31,17",
"49,67,2", "25", "70,71,8", "74", "76,11", "77,25", "4,45,13",
"11,78,65", "42", "84,14,85", "61", "86", "87,62,72,49", "2,44,89,90",
"92", "8", "47", "14", "29", "12", "99", "93", "62", "10", "68,20",
"5", "49", "12,32,92,29,14", "59", "3,8", "111,112,92", "15",
"117", "119,104,120", "121,122", "92", "123,124", "125", "36,125,43,56,126,127",
"69", "22", "97", "15,49", "8", "99,129,30", "49", "131,110",
"11,20", "3,133,30", "72", "124,136", "8", "20", "90,46,140,106",
"110", "11,14,12", "8", "15", "50,5", "104", "11,13", "1,2",
"13", "147,12,36,148,70,15,110,14", "103,43,90,38,13", "116,149",
"8,73", "62,115", "46,150", "40", "7", "120", "18,62,77", "96",
"8", "77", "126", "144", "30", "5", "30", "69", "25", "13", "67",
"110", "68,72", "110", "30,107", "96,95", "113", "115", "46",
"8", "25", "3,49", "5", "14", "102", "30", "38", "91,10,45,104,167",
"59", "96", "67,150", "11,29", "74,11", "14,113", "14,47,156,5",
"70", "23", "14,171", "17,101,152,12", "153,11", "101,165,4",
"103,173", "11,22,8", "136,37", "46", "5", "70,71", "11,45,177,159,8",
"59", "22,5,11,77,20", "93,36", "5,147", "40", "110,11", "159,131",
"74", "43,150", "1", "30", "183", "30", "13,81,8", "8", "23",
"23")), row.names = c(NA, -500L), class = c("data.table", "data.frame"
))
I tried tons of confidence and support parameters to get any rules by apriori, minlen should be fixed at 2 but in this case no rules are returned.
library(data.table)
library(arules)
fwrite(df,'basket.csv',row.names = TRUE,sep = ':')
txn <- read.transactions(file="basket.csv", rm.duplicates= TRUE, format="basket",sep=":",cols=1)
basket_rules <- apriori(txn,parameter = list(supp=0.01, conf=0.08,target="rules",minlen = 2))
Thanks in advance.