arules

Arules returning empty LHS

跟風遠走 提交于 2019-11-30 15:48:57
问题 I have a dataset which looks like this: "user.get","search_restaurants","cuisines.get" "user.get","search_restaurants","user.get","search_restaurants" "order/address/get_user_addresses" "search_restaurants","search_restaurantssearch_restaurants" "restaurant.get","search_restaurants","order/menu","restaurant.get","restaurant.get","restaurant.get","order/menu","order/menu","restaurant.get","restaurant.getsearch_restaurantsrestaurant.get","user.get","order/menu","order/menu","get_user_reviews

Arules returning empty LHS

橙三吉。 提交于 2019-11-30 15:42:07
I have a dataset which looks like this: "user.get","search_restaurants","cuisines.get" "user.get","search_restaurants","user.get","search_restaurants" "order/address/get_user_addresses" "search_restaurants","search_restaurantssearch_restaurants" "restaurant.get","search_restaurants","order/menu","restaurant.get","restaurant.get","restaurant.get","order/menu","order/menu","restaurant.get","restaurant.getsearch_restaurantsrestaurant.get","user.get","order/menu","order/menu","get_user_reviews_filtered","order/menu","restaurant.get" When I run the apriori algorithm on it: txn1 = read.transactions

Association rule in R - removing redundant rule (arules)

白昼怎懂夜的黑 提交于 2019-11-30 10:15:29
Assume we have 3 rules: [1] {A,B,D} -> {C} [2] {A,B} -> {C} [3] Whatever it is Rule [2] is a subset of rule [1] (because rule [1] contains all the items in rule [2] ), so rule [1] should be eliminated (because rule [1] is too specific and its information is included in rule [2] ) I searched through the internet and everyone is using these code to remove redundant rules: subset.matrix <- is.subset(rules.sorted, rules.sorted) subset.matrix[lower.tri(subset.matrix, diag=T)] <- NA redundant <- colSums(subset.matrix, na.rm=T) >= 1 which(redundant) rules.pruned <- rules.sorted[!redundant] I dont

How to get items for both LHS and RHS for only specific columns in arules?

白昼怎懂夜的黑 提交于 2019-11-30 05:45:47
问题 Within the apriori function, I want the outcome to only contain these two variables in the LHS HouseOwnerFlag=0 and HouseOwnerFlag=1 . The RHS should only contain attributes from the column Product . For instance: # lhs rhs support confidence lift # 1 {HouseOwnerFlag=0} => {Product=SV 16xDVD M360 Black} 0.2500000 0.2500000 1.000000 # 2 {HouseOwnerFlag=1} => {Product=Adventure Works 26" 720p} 0.2500000 0.2500000 1.000000 # 3 {HouseOwnerFlag=0} => {Product=Litware Wall Lamp E3015 Silver} 0

Load a dataset into R with data() using a variable instead of the dataset name

对着背影说爱祢 提交于 2019-11-30 02:01:50
问题 I am trying to load a dataset into R using the data() function. It works fine when I use the dataset name (e.g. data(Titanic) or data("Titanic") ). What doesn't work for me is loading a dataset using a variable instead of its name. For example: # This works fine: > data(Titanic) # This works fine as well: > data("Titanic") # This doesn't work: > myvar <- Titanic > data(myvar) **Warning message: In data(myvar) : data set ‘myvar’ not found** Why is R looking for a dataset named "myvar" since it

Sorting rules by lift and confidence

橙三吉。 提交于 2019-11-29 15:47:37
I am trying to find association rules using the apriori function from arules package in R. rules <- apriori(data=data, parameter=list(supp=0.001,conf = 0.08), appearance = list(default="lhs",rhs="YOGHURT"), control = list(verbose=F)) rules <- sort(rules, decreasing=TRUE,by="confidence") inspect(rules[1:3]) lhs rhs support confidence lift 1. {A,B} {C} 0.04 0.96 0.25 2. {C,A} {D} 0.05 0.95 0.26 3. {B,D} {A,C} 0.03 0.93 0.24 With the code showed above I got some association rules saved in the variable "rules" ordered by confidence in a decreasing way. But I would like to order these rules by

How to prep transaction data into basket for arules

若如初见. 提交于 2019-11-27 22:27:21
Ok, so I have searched a lot and want to run arules on sales data. I just need to properly get the data in the right format and set up with the correct "factors" or "variables" and in basket form. Right now I have sales data with the Order# and then the items inside that. Each order is unique (every new order, a new # gets created and includes the part#), but the same items obviously can appear in many orders. Currently, my data is set up like this: Order# Part# PartDescription 1 A PartA 1 B PartB 1 G PartG 2 R PartR 3 A PartA 3 B PartB 4 E PartE 5 Y PartY 6 A PartA 6 B PartB 6 F PartF 6 V

how to convert data.frame to transactions for arules

﹥>﹥吖頭↗ 提交于 2019-11-27 03:34:59
I read data from a csv file, the data has 3 columns, one is transaction id, the other two are product and product catagory. I need to convert this into transactions in order to use the apriori function in arules . It shows an error when I convert to transactions: dat <- read.csv("spss.csv",head=TRUE,sep="," , as.is = T) dat[,2] <- factor(dat[,2]) dat[,3] <- factor(dat[,3]) spssdat <- dat[,c(1,2,3)] str(spssdat) 'data.frame': 108919 obs. of 3 variables: $ Transaction_id: int 3000312 3000312 3001972 3003361 3003361 3003361 3003361 3003361 3003361 3004637 ... $ product_catalog : Factor w/ 9

How to prep transaction data into basket for arules

纵然是瞬间 提交于 2019-11-26 20:59:28
问题 Ok, so I have searched a lot and want to run arules on sales data. I just need to properly get the data in the right format and set up with the correct "factors" or "variables" and in basket form. Right now I have sales data with the Order# and then the items inside that. Each order is unique (every new order, a new # gets created and includes the part#), but the same items obviously can appear in many orders. Currently, my data is set up like this: Order# Part# PartDescription 1 A PartA 1 B

how to convert data.frame to transactions for arules

我的未来我决定 提交于 2019-11-26 10:35:08
问题 I read data from a csv file, the data has 3 columns, one is transaction id, the other two are product and product catagory. I need to convert this into transactions in order to use the apriori function in arules . It shows an error when I convert to transactions: dat <- read.csv(\"spss.csv\",head=TRUE,sep=\",\" , as.is = T) dat[,2] <- factor(dat[,2]) dat[,3] <- factor(dat[,3]) spssdat <- dat[,c(1,2,3)] str(spssdat) \'data.frame\': 108919 obs. of 3 variables: $ Transaction_id: int 3000312