Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rules with multiple items in the RHS #51

Open
mhahsler opened this issue Feb 22, 2019 · 3 comments
Open

Rules with multiple items in the RHS #51

mhahsler opened this issue Feb 22, 2019 · 3 comments

Comments

@mhahsler
Copy link
Owner

Add code to produce rules with more than 1 items in the RHS in function ruleInduction().

@srah99
Copy link

srah99 commented Dec 4, 2023

I found this error doing an assignment that I could not finish because of it. I made a file to help but seem to confuse working on the package to wanting to install the package.

@srah99
Copy link

srah99 commented Dec 4, 2023

#would this work?

Install the devtools package if you haven't already

install.packages("devtools")

Fork the arules repository on GitHub and clone it to your local machine

Make modifications to the arules source code to handle multiple items on the RHS

Build and install the modified arules package

devtools::install("<path_to_your_local_arules_clone>")

Load the modified arules package

library(arules)

Function to perform rule induction with multiple items on RHS

ruleInduction <- function(data, min_support, min_confidence, rhs_items) {

Convert data to transactions

transactions <- read.transactions(data, format = "basket", sep = ",", cols = c("TransactionID", "Items"))

Mine association rules with modified apriori function

rules <- apriori(transactions, parameter = list(support = min_support, confidence = min_confidence), rhs_items = rhs_items)

Print the modified rules

print(rules)
}

Example usage

data <- "TransactionID,Items
1,A, B, C
2,A, B
3,B, C
4,A, C
5,B"

min_support <- 0.2
min_confidence <- 0.7
rhs_items <- c("B", "C")

Call the function

ruleInduction(data, min_support, min_confidence, rhs_items)

@mhahsler
Copy link
Owner Author

mhahsler commented Dec 4, 2023

Do you have an implementation of rule induction with multiple items in the RHS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants