Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi,
the apriori function used with a dataset returns a very small number of rules
library(arules)
library(methods)
#specific for Your data type
SalesData <- as(dataset,"transactions")
# matrix
SalesData2=as.data.frame(as(SalesData, "matrix"))
SalesData2=cbind(id=1:nrow(SalesData2),SalesData2)
#
Temp<-apriori(SalesData2, parameter = list(support = 0.006, confidence = 0.25, minlen = 2, maxlen = 2, target = "rules"))
#
output<-inspect(sort(Temp, by = "lift")[1:6])
only 6 combinations appear instead of 700
While the same function used with a CSV file (same data & columns) returns to me 700 rules
# 'dataset'
library(Matrix)
library(arules)
library(dplyr)
#
SalesData <- read.transactions("...Data.csv", sep = ";")
SalesData<-SalesDate[-1,]
#
Temp<-apriori(SalesData, parameter = list(support = 0.006, confidence = 0.25, minlen = 2, maxlen = 2,target="rules"))
#
#output<-inspect(Temp[1:700])
output<-inspect(Temp[1:length(Temp)])
#output<-inspect(sort(Temp, by = "lift")[1:700])
I think I'm using my dataset wrong (query M)
With or without Matrix I return a very low number of lines
Thanks for your help
Christophe (France power BI "fan")
Solved! Go to Solution.
I found a workaround
library(arules)
library(methods)
# 'dataset' contient les données d'entrée pour ce script
basket_rules<-apriori(dataset, parameter = list(support = 0.006, confidence = 0.10, minlen = 2, maxlen = 2, target = "rules"))
df_basket <- as(basket_rules,"data.frame")
#View(df_basket)
This script provides all rules ...
@Bamak ,
This issue should caused by apriori() function:
apriori(data, parameter = NULL, appearance = NULL, control = NULL)
From the R documentation:
parameter: object of class '>APparameter
or named list. The default behavior is to mine rules with minimum support of 0.1, minimum confidence of 0.8, maximum of 10 items (maxlen), and a maximal time for subset checking of 5 seconds (maxtime).
So you can try changing the maxlen subparameter.
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I found a workaround
library(arules)
library(methods)
# 'dataset' contient les données d'entrée pour ce script
basket_rules<-apriori(dataset, parameter = list(support = 0.006, confidence = 0.10, minlen = 2, maxlen = 2, target = "rules"))
df_basket <- as(basket_rules,"data.frame")
#View(df_basket)
This script provides all rules ...
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
76 | |
76 | |
55 | |
37 | |
34 |
User | Count |
---|---|
99 | |
56 | |
53 | |
44 | |
40 |