0

I am working on Association Rules so I need transactional dataset which is unavailable on UCI repository so I need to generate transactional data. Transactional data is a set of transactions and each transaction have subset of items. Groceries data is a example of Transactional database. Let D be a transactional database and T be a transactions t={t1,t2,t3 ...... tn} and I be a set of items I={i1,i2,i3, ..... im} then transactional data looks like

TID Items
001 i1,i2,i5
002 i5,i6,i8,i10
003 i1,i4
004 i6,i4,i8
Thanks

2 Answers2

0

So based off of your definition what it looks like you're trying to do is generate a two dimensional array. In JavaScript you could do something like this:

var t = 5, d = [], r = 10, s = 10; 
for(var i=0; i<t; i++){
    d.push([]);
    for(var j=0; j<Math.random()*r; j++){
        d[i].push("i"+Math.floor(Math.random()*s))
    }
}

Here we let t be the number of transactions, d be the two dimensional array of transactions, r be the maximum number of transactions in row i and s be the maximum value of some number in the string (i+someNumber). Running the above and printing out d (console.log(d)) could give you something like this:

0 i3, i8
1 i5, i6, i8
2 i1, i2, i5
3 i3, i8 
4 i9, i1, i7, i3, i5
winhowes
  • 7,845
  • 5
  • 28
  • 39
0

Here is an opensource app that leverages the R package conjurer to generate transactional data.