Hoju
Hoju

Reputation: 139

Is it possible to use arules package with MySQL database?

I have a local MySQL database too big to fit in memory. I need to use the apriori() function with some tables.

From the arules documentation I don't see how this can be done.

apriori(data, parameter = NULL, appearance = NULL, control = NULL)

data object of class transactions or any data structure which can be coerced into transactions (e.g., a binary matrix or data.frame).

I've found a package that does exactly what I want but It is for IBM DB2, not MySQL.

Anyone knows how/if this can be done? Thanks.

Edit: There is no way to do this with arules and, as far as I know, no way to do this in R. I've found this demo to use the apriori algorithm in a MySQL database but unfortunately it doesn't work anymore.

Upvotes: 0

Views: 98

Answers (1)

Michael Hahsler
Michael Hahsler

Reputation: 3075

You cannot directly use database with the apriori implementation in arules. You need to select the data you want into a data.frame that hopefully fits into memory, and then convert the data.frame into a transactions object. You could use a sample if it does not fit into memory.

Upvotes: 0

Related Questions