-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFPGrowth.java
40 lines (31 loc) · 1.27 KB
/
FPGrowth.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.ArrayList;
public class FPGrowth {
@SuppressWarnings("unchecked")
public static void main(String[] args) throws FileNotFoundException {
File f = new File(args[0]);
double minsup = Double.parseDouble(args[1]);
PrintWriter outfile = new PrintWriter("MiningResult.txt");
try {
// Generate the global FP-tree
FPTree globalTree = new FPTree(f, minsup);
// Recursively build every projected FP-tree
globalTree.generateProjectedTrees();
// Obtain results by recursively tracing through every projected tree
int numFrequentPatterns = globalTree.numFrequentPatterns();
String miningResult = globalTree.miningResult();
// Print to standard out and to output file as per assignment specification
System.out.println("|FPs| = " + numFrequentPatterns);
outfile.println("|FPs| = " + numFrequentPatterns);
outfile.print(miningResult);
} catch (IOException ioe) {
System.out.print(ioe);
System.exit(0);
} finally {
outfile.close();
}
}
}