Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I am having trouble with this question, I have completed most of the question but I cannot seem figure out how the last 2

image text in transcribed

Hello I am having trouble with this question, I have completed most of the question but I cannot seem figure out how the last 2 bullet points:

Implement Multistage (3 Passes) version of PCY, using one extra hash table. (add the results to the line chart) Implement Multihash version of PCY, using one extra hash table. (add the results to the line chart)

Since the question is very long and I have many classes/java files created I have only included the PCY code since it is the relevant file needed for the last 2 bullets.

/////////////////////////////////////////////////////////PCY Code///////////////////////////////////////////////////////////////////////

package project;

import java.io.*; import java.util.*; public final class PCY { //Variables private static int limit,maxSize = 131072;// set the size to 2^17 private static BitSet bit; //Setters public static void setBucketSize(int bSize) { maxSize = bSize; } public static void setLimit(int p ) { limit = p ; } //Link the hash maps public static LinkedHashMap toFindPair(String retail) throws NumberFormatException, IOException { HashMap ItemFrequent = PCYPassOne(retail); LinkedHashMap canBeSet = new LinkedHashMap(); String _line,numberOfLines[]; Integer key; ArrayList myList = new ArrayList(); FileReader toReadFile = new FileReader(retail); BufferedReader reader = new BufferedReader(toReadFile); while ((_line = reader.readLine()) != null) { numberOfLines = _line.split("\\s+"); for (String toNum : numberOfLines) { /*convert to integer*/ key = Integer.parseInt(toNum); if (ItemFrequent.containsKey(key) && !myList.contains(key)) { myList.add(key); } } /*sort myList*/ Collections.sort(myList); for (int n = 0; n val = new Set1(myList.get(n), myList.get(k)); if (!bit.get(Math.abs(val.hashCode()) % maxSize)) { continue; } if (canBeSet.containsKey(val)) { canBeSet.put(val, canBeSet.get(val) + 1); } else { canBeSet.put(val, 1); } } } myList.clear(); } reader.close(); removeNotFrequent(canBeSet); /*return frequent pairs and number of support*/ return canBeSet; } /* first pass -- to find freq Item Counts */ private static HashMap PCYPassOne(String fileName) throws NumberFormatException, IOException { //Decelerations HashMap pass1 = new HashMap(); Bucket firstBucket = new Bucket(maxSize); String totalLine[], _lin = ""; Integer value; ArrayList myList = new ArrayList(); FileReader readFile = new FileReader(fileName); BufferedReader reader = new BufferedReader(readFile); while ((_lin = reader.readLine()) != null) { totalLine = _lin.split("\\s+"); for (String num : totalLine) { value = Integer.parseInt(num); if (pass1.containsKey(value)) { pass1.put(value, pass1.get(value) + 1); } else { pass1.put(value, 1); } if (!myList.contains(value)) { myList.add(value); } } Collections.sort(myList); for (int n = 0; n val = new Set1 (myList.get(n), myList.get(k)); if (firstBucket.haveKey(val)) { firstBucket.input(val, firstBucket.get(val) + 1); } else { firstBucket.input(val, 1); } } } myList.clear(); } reader.close(); removeNotFrequent(pass1); bit = firstBucket.toBit(limit); firstBucket = null; return pass1; } private static boolean checkFrequancy(int num) { return num >= limit; } /*To remove none freq. Pair*/ private static void removeNotFrequent(HashMap map) { Iterator> check = map.entrySet().iterator(); while (check.hasNext()) { Map.Entry entry = check.next(); if (!checkFrequancy(entry.getValue())) { check.remove(); } } } /*To remove none freq. Pair*/ private static void removeNotFrequent(LinkedHashMap map) { Iterator> check = map.entrySet().iterator(); while (check.hasNext()) { Map.Entry entry = check.next(); if (!checkFrequancy(entry.getValue())) { check.remove(); } } } }

Description The main objective of this project is to find frequent itemsets by implementing two efficient algorithms: A-Priori and PCY. The goal is to find frequent pairs of elements. You do not need to find triples and larger itemsets. Dataset The retail dataset contains anonymized retail market basket data (88K baskets) from an anonymous retail store. The preprocessing step to map text labels into integers has already been done. Use Sublime Text, TextPad or Notepad++ or other software to open the file. Do not use Notepad. Experiments Perform the scalability study for finding frequent pairs of elements by dividing the dataset into different chunks and measure the time performance. Provide the line chart. Provide results for the following support thresholds: 1%, 5%, 10%. For example, if your chunk is 10% of the dataset, you have around 8,800 baskets. Therefore, if your support threshold is 5%, you should count the pairs that appear in at least 440 baskets. See three samples below for three different support thresholds. Implement Multistage (3 Passes) version of PCY, using one extra hash table. (add the results to the line chart) Implement Multihash version of PCY, using one extra hash table. (add the results to the line chart) O Description The main objective of this project is to find frequent itemsets by implementing two efficient algorithms: A-Priori and PCY. The goal is to find frequent pairs of elements. You do not need to find triples and larger itemsets. Dataset The retail dataset contains anonymized retail market basket data (88K baskets) from an anonymous retail store. The preprocessing step to map text labels into integers has already been done. Use Sublime Text, TextPad or Notepad++ or other software to open the file. Do not use Notepad. Experiments Perform the scalability study for finding frequent pairs of elements by dividing the dataset into different chunks and measure the time performance. Provide the line chart. Provide results for the following support thresholds: 1%, 5%, 10%. For example, if your chunk is 10% of the dataset, you have around 8,800 baskets. Therefore, if your support threshold is 5%, you should count the pairs that appear in at least 440 baskets. See three samples below for three different support thresholds. Implement Multistage (3 Passes) version of PCY, using one extra hash table. (add the results to the line chart) Implement Multihash version of PCY, using one extra hash table. (add the results to the line chart) O

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago