Creating Hash table for counting pairs, triplets,… in frequent itemset mining
up vote
0
down vote
favorite
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class FreqItemset
// method to read parameters of file ( bucket and min sup)
public int no_of_baskets_and_minsup(BufferedReader br) throws IOException
String line1 = br.readLine();
return new int Integer.parseInt(line1.split(" ")[0]), Integer.parseInt(line1.split(" ")[1]);
public void pass1(String file)
try
BufferedReader inputbr = new BufferedReader(new FileReader(file));
int res = no_of_baskets_and_minsup(inputbr);
int baskets = res[0];
int minsup = res[1];
System.out.println("Number of bukcets:"+baskets);
System.out.println("Min support is:"+minsup);
//pass 1 logic
String basket=null;
int unique_items = new int[100];
while( (basket = inputbr.readLine()) !=null ) // for each basket
String temp = basket.split(",");
for(int i =1; i<temp.length; i++) // for each item in basket
unique_items[Integer.parseInt(temp[i])]++; // increment counts
//todo create hashtable maintaing bukcet and count
//For each pair of items in a basket..
// hash the pair to a bukce;
// add 1 to the count of that bukcet;
catch (Exception ex)
System.out.println("Something wrong in Phase 1 :" + ex.getMessage() + "nn" + ex.getStackTrace());
public static void main(String args)
String filename = "input.txt";
long t1= System.currentTimeMillis();
FreqItemset obj = new FreqItemset();
obj.pass1(filename);
long t2= System.currentTimeMillis();
System.out.println("Time mili "+(t2-t1));
In implementing the PCY algorithm with Multihash technique for Frquent itemset mining .. in the pass 1 i need have created an array of 1-itemsets and their counts. Now i need to consider each pair from each basket and hash it to bucket using a hash function. I have to create 2 has tables in Pass 1 ( multihash PCY).
I am unable to figure a way : given a pair i,j of items how shoud i implement hash-table using my own has function like eg. (i*j)%51 and other similar one for second hash-table.
I read alot about hashing hashtables but didnt find a way out .
java apriori
add a comment |
up vote
0
down vote
favorite
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class FreqItemset
// method to read parameters of file ( bucket and min sup)
public int no_of_baskets_and_minsup(BufferedReader br) throws IOException
String line1 = br.readLine();
return new int Integer.parseInt(line1.split(" ")[0]), Integer.parseInt(line1.split(" ")[1]);
public void pass1(String file)
try
BufferedReader inputbr = new BufferedReader(new FileReader(file));
int res = no_of_baskets_and_minsup(inputbr);
int baskets = res[0];
int minsup = res[1];
System.out.println("Number of bukcets:"+baskets);
System.out.println("Min support is:"+minsup);
//pass 1 logic
String basket=null;
int unique_items = new int[100];
while( (basket = inputbr.readLine()) !=null ) // for each basket
String temp = basket.split(",");
for(int i =1; i<temp.length; i++) // for each item in basket
unique_items[Integer.parseInt(temp[i])]++; // increment counts
//todo create hashtable maintaing bukcet and count
//For each pair of items in a basket..
// hash the pair to a bukce;
// add 1 to the count of that bukcet;
catch (Exception ex)
System.out.println("Something wrong in Phase 1 :" + ex.getMessage() + "nn" + ex.getStackTrace());
public static void main(String args)
String filename = "input.txt";
long t1= System.currentTimeMillis();
FreqItemset obj = new FreqItemset();
obj.pass1(filename);
long t2= System.currentTimeMillis();
System.out.println("Time mili "+(t2-t1));
In implementing the PCY algorithm with Multihash technique for Frquent itemset mining .. in the pass 1 i need have created an array of 1-itemsets and their counts. Now i need to consider each pair from each basket and hash it to bucket using a hash function. I have to create 2 has tables in Pass 1 ( multihash PCY).
I am unable to figure a way : given a pair i,j of items how shoud i implement hash-table using my own has function like eg. (i*j)%51 and other similar one for second hash-table.
I read alot about hashing hashtables but didnt find a way out .
java apriori
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class FreqItemset
// method to read parameters of file ( bucket and min sup)
public int no_of_baskets_and_minsup(BufferedReader br) throws IOException
String line1 = br.readLine();
return new int Integer.parseInt(line1.split(" ")[0]), Integer.parseInt(line1.split(" ")[1]);
public void pass1(String file)
try
BufferedReader inputbr = new BufferedReader(new FileReader(file));
int res = no_of_baskets_and_minsup(inputbr);
int baskets = res[0];
int minsup = res[1];
System.out.println("Number of bukcets:"+baskets);
System.out.println("Min support is:"+minsup);
//pass 1 logic
String basket=null;
int unique_items = new int[100];
while( (basket = inputbr.readLine()) !=null ) // for each basket
String temp = basket.split(",");
for(int i =1; i<temp.length; i++) // for each item in basket
unique_items[Integer.parseInt(temp[i])]++; // increment counts
//todo create hashtable maintaing bukcet and count
//For each pair of items in a basket..
// hash the pair to a bukce;
// add 1 to the count of that bukcet;
catch (Exception ex)
System.out.println("Something wrong in Phase 1 :" + ex.getMessage() + "nn" + ex.getStackTrace());
public static void main(String args)
String filename = "input.txt";
long t1= System.currentTimeMillis();
FreqItemset obj = new FreqItemset();
obj.pass1(filename);
long t2= System.currentTimeMillis();
System.out.println("Time mili "+(t2-t1));
In implementing the PCY algorithm with Multihash technique for Frquent itemset mining .. in the pass 1 i need have created an array of 1-itemsets and their counts. Now i need to consider each pair from each basket and hash it to bucket using a hash function. I have to create 2 has tables in Pass 1 ( multihash PCY).
I am unable to figure a way : given a pair i,j of items how shoud i implement hash-table using my own has function like eg. (i*j)%51 and other similar one for second hash-table.
I read alot about hashing hashtables but didnt find a way out .
java apriori
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class FreqItemset
// method to read parameters of file ( bucket and min sup)
public int no_of_baskets_and_minsup(BufferedReader br) throws IOException
String line1 = br.readLine();
return new int Integer.parseInt(line1.split(" ")[0]), Integer.parseInt(line1.split(" ")[1]);
public void pass1(String file)
try
BufferedReader inputbr = new BufferedReader(new FileReader(file));
int res = no_of_baskets_and_minsup(inputbr);
int baskets = res[0];
int minsup = res[1];
System.out.println("Number of bukcets:"+baskets);
System.out.println("Min support is:"+minsup);
//pass 1 logic
String basket=null;
int unique_items = new int[100];
while( (basket = inputbr.readLine()) !=null ) // for each basket
String temp = basket.split(",");
for(int i =1; i<temp.length; i++) // for each item in basket
unique_items[Integer.parseInt(temp[i])]++; // increment counts
//todo create hashtable maintaing bukcet and count
//For each pair of items in a basket..
// hash the pair to a bukce;
// add 1 to the count of that bukcet;
catch (Exception ex)
System.out.println("Something wrong in Phase 1 :" + ex.getMessage() + "nn" + ex.getStackTrace());
public static void main(String args)
String filename = "input.txt";
long t1= System.currentTimeMillis();
FreqItemset obj = new FreqItemset();
obj.pass1(filename);
long t2= System.currentTimeMillis();
System.out.println("Time mili "+(t2-t1));
In implementing the PCY algorithm with Multihash technique for Frquent itemset mining .. in the pass 1 i need have created an array of 1-itemsets and their counts. Now i need to consider each pair from each basket and hash it to bucket using a hash function. I have to create 2 has tables in Pass 1 ( multihash PCY).
I am unable to figure a way : given a pair i,j of items how shoud i implement hash-table using my own has function like eg. (i*j)%51 and other similar one for second hash-table.
I read alot about hashing hashtables but didnt find a way out .
java apriori
java apriori
edited Nov 10 at 0:08
Harry Coder
2001417
2001417
asked Nov 9 at 21:07
ADITYA SURVE
13
13
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233284%2fcreating-hash-table-for-counting-pairs-triplets-in-frequent-itemset-mining%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown