Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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 ...
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |