arules

Cannot convert dataframe to transactions object

◇◆丶佛笑我妖孽 提交于 2019-12-25 07:26:42
问题 I want to use the arules package to practice mining association rules with R. The data is datt <- structure(list(Item1 = c(0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L), Item2 = c(0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 0L), Item3 = c(0L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L), Item4 = c(0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L), Item5 = c(1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L), Item6 = c(0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L ), Item7 = c(0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L), Item8 = c(0L, 1L, 1L, 1L,

How could we know the ColumnName /attribute of items generated in Rules

夙愿已清 提交于 2019-12-25 07:15:19
问题 Using arules package, 'apriori' returns a 'rules' object. How can we make a query that - What exact column does the item(s) in rules {lhs, rhs} come from ? Example: I've some data in a tabular manner in file "input.csv" and want to associate/interpret the returned rule itemsets with the column headers in the file. How can I possibly do that? Any pointers are appreciated. Thanks, A reproducible example: input.csv ABC,DEF,GHI,JKL,MNO 11,56789,1,0,10 12,57685,0,0,10 11,56789,0,1,11 10,57689,1,0

deploying apriori rulsets to the dataset in R

元气小坏坏 提交于 2019-12-24 08:28:14
问题 I have a question regarding apriori rule deployment in R. I basically want to assign a predcition(item) and a confidence value to each customer so I can create a simple recommending system, so below is a subset of my rule set which I have obtained, bread&wine -> meat (confidence 54%) cheese -> fruit (confidence 43%) bread&cheese -> frozveg (confidence 24%) and the following is simple representation of what I want to achieve with just 1 customer; this is in a basket or truth-table data. ID

R arules : Extract lhs items from rules

最后都变了- 提交于 2019-12-24 07:28:12
问题 I want to extract lhs items from a rule generated from arules. For example, {a,b,c} => {d} I want to be able to extract a,b,c and put it in a character vector, so I can iterate and do further processing based on these items. At the moment, I can think of parsing the set of rules, converting it to a data frame and then separate these items using character manipulation/regex. I hope there's better way of extracting these items. 回答1: Just coerce the LHS and/or the RHS into a list: data("Adult")

Adding item information to transaction object in arules

不羁的心 提交于 2019-12-23 01:57:15
问题 I am using the arules package to find association rules in point-of-sale retail data. I am extracting transaction detail from a database, then placing in a transaction object. I'm new to arules and am trying to figure out how to populate the itemInfo data frame in the transaction object. Right now, I'm just bringing in the transaction and item ID s (both numeric), which provide little context. I would like to be able to add an item description, as well as product hierarchy levels. Below is

Association analysis with duplicate transactions using arules package in R

半腔热情 提交于 2019-12-21 04:38:22
问题 I want to create a transaction object in basket format which I can call anytime for my analyses. The data contains comma separated items with 1001 transactions. The first 10 transactions look like this: hering,corned_b,olives,ham,turkey,bourbon,ice_crea baguette,soda,hering,cracker,heineken,olives,corned_b avocado,cracker,artichok,heineken,ham,turkey,sardines olives,bourbon,coke,turkey,ice_crea,ham,peppers hering,corned_b,apples,olives,steak,avocado,turkey sardines,heineken,chicken,coke,ice

Sorting rules by lift and confidence

十年热恋 提交于 2019-12-18 09:21: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

How to upload arules package in R

馋奶兔 提交于 2019-12-14 03:35:46
问题 I am not able to upload arules package Below is the following command I am using library(arules) I have downloaded the file from http://cran.r-project.org/web/packages/arules/index.html still it is not able to upload it. Can anyone help me out 回答1: install.packages("arules") pls. find below GUI - Screen for Rcmdr Package Open RStudio . Go to the “Packages” tab and click on “Install Packages” . The first time you’ll do this you’ll be prompted to choose a CRAN mirror . R will download all

Data (csv) into basket for arules, removing duplicates?

梦想与她 提交于 2019-12-13 17:19:52
问题 I'm a beginner when it comes to R. But, I want to learn more. I'm trying to do a market bench analysis. This is my raw data and I want to convert this to a transactions basket format: This is what I am trying to achieve: I have tried : trans <- as(split(a[,"Game.played"],a[,"sessionid"]),"transactions") But, instead of the name of the game, the number of the game is only displayed. Could anyone tell me why this is happening? Also, I have cross verifies the actual data, and the association of

R (arules) Convert dataframe into transactions and remove NA

一笑奈何 提交于 2019-12-12 04:38:21
问题 i have a set dataframe. My purpose is to convert the dataframe into transactions data in order to do market basket analysis using Arules package in R. I did do some research online regarding conversion of dataframe to transactions data, e.g.(How to prep transaction data into basket for arules) and (Transform csv into transactions for arules), but the result i got was different. dput(df) structure(list(Transaction_ID = c("A001", "A002", "A003", "A004", "A005", "A006"), Fruits = c(NA, "Apple",