i first imported a data from a csv file then took one column to turn to transactions to use
I = data$items
write.table(I, "output.txt", row.names = FALSE, col.names = FALSE)
transactions <- read.transactions("output.txt",sep = ",")
inspect(transactions)
while (TRUE) {
min_support <- as.numeric(readline(prompt = "Enter the minimum support (between 0.001 and 1): "))
min_confidence <- as.numeric(readline(prompt = "Enter the minimum confidence (between 0.001 and 1): "))
if ((min_support < 1 && min_support > 0.001) && (min_confidence < 1 && min_confidence > 0.001)) {
break
} else {
print("Error: Support and confidence values must be between 0.001 and 1.")
}
}
apriori_rules <- apriori(transactions, parameter = list(supp = min_support, conf = min_confidence, minlen=2))
print(apriori_rules)
inspect(apriori_rules)
the result i got: (note the minimum spp and conf are given in the assignment so they are suitable)
Enter the minimum support (between 0.001 and 1): 0.002
Enter the minimum confidence (between 0.001 and 1): 0.002
> apriori_rules <- apriori(transactions, parameter = list(supp = min_support, conf = min_confidence, minlen=2))
Apriori
Parameter specification:
confidence minval smax arem aval originalSupport maxtime support minlen maxlen
0.002 0.1 1 none FALSE TRUE 5 0.002 2 10
target ext
rules TRUE
Algorithmic control:
filter tree heap memopt load sort verbose
0.1 TRUE TRUE FALSE TRUE 2 TRUE
Absolute minimum support count: 19
set item appearances ...[0 item(s)] done [0.00s].
set transactions ...[7011 item(s), 9835 transaction(s)] done [0.01s].
sorting and recoding items ... [32 item(s)] done [0.00s].
creating transaction tree ... done [0.00s].
checking subsets of size 1 done [0.00s].
writing ... [0 rule(s)] done [0.00s].
creating S4 object ... done [0.00s].
New contributor
Zeianb Elsayed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.