⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 partitionndi.java

📁 数据挖掘中的Aprior算法java实现
💻 JAVA
字号:
package datamining;

import java.io.*;
import java.util.*;

/**
 Partition with NDI
 Does the same routines as the Partition algorithm, but looks only for non- derivable frequent itemsets.
 */



/**
 * Class for implementing partition algorithm for
 * finding non-derivable frequent itemsets.
 *
 * @author Michael Holler
 * @version 0.1, 18.03.2004
 */
public class PartitionNDI extends Partition {

  /**
   * Default contructor for creating a PartitionNDI object.
   */
  public PartitionNDI() {

  }

  /**
   * Constructur for creating a PartitionNDI object with parameters.
   *
   * @param	filename	the name of the database file
   * @param	minsup		the minimal support threshold
   * @param	partsize	rows read from the database in one scan	
   */ 
  public PartitionNDI(String filename, int minsup, int partsize, int partcount) {
    super(filename, minsup, partsize, partcount); 
  }

  /**
   * The workhorse method that implements the partition algorithm.
   */  
  public void findFrequentSets() { 
    int fine, merged, generated;
    NDI ndi;

    dh.setPartsize(this.partsize);
    int counter = partcount;

    while (counter > 0) {	    
      ndi = new NDI(localsupport, this.dh);
      ndi.findFrequentSets(); 
      this.localroot = ndi.getTrie();
      generated = Tools.zeroSupport(localroot);	// only needed for counting 
      merged = mergeTrie(globalroot, localroot);
      total += merged;
      System.out.println("total: " + this.total + 
		         ", generated: " + generated +
			 ", merged: " + merged); 
      counter--;
      dh.nextPart();
    }
    dh = new DataHandler(filename);
    Tools.countSupport(globalroot, dh);
    fine = pruneCandidates(globalroot, globalsupport);
    
    this.total = fine;
    System.out.println("\nFrequent sets found: " + this.total + ".");
  }

  /**
   * Main method for testing the algorithm.
   *
   * @param 	args	the arguments can contain the filename
   * 			of the testfile and the minimal support
   * 			threshold and a filename for output
   */
  public static void main(String args[]) {
    String testfile = "test.dat";
    String outfile = "";
    int support = 4;
    int size = 4;
    int count = 4;
    try {
      testfile = args[0];
    } catch (Exception e) {
      System.out.println("Didn't get filename. Using '" + testfile + "'.");
    }
    try {
      support = new Integer(args[1]).intValue();
    } catch (Exception e) {
      System.out.println("Didn't get support threshold. Using '" + support + "'.");
    }	    

    try {
      size = new Integer(args[2]).intValue();
    } catch (Exception e) {
      System.out.println("Didn't get partsize. Using '" + size + "'.");
    }

    try {
      count = new Integer(args[3]).intValue();
    } catch (Exception e) {
      System.out.println("Didn't get partcount. Using '" + count + "'.");
    }
    
    StopWatch sw = new StopWatch();
    sw.start();
    PartitionNDI part = new PartitionNDI(testfile, support, size, count);
    part.findFrequentSets();
    sw.stop();
    sw.print();
  }

}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -