/* -------------------------------------------------------------------------- */
/* */
/* ASSOCIATION RULE DATA MINING */
/* */
/* Frans Coenen */
/* */
/* Wednesday 9 January 2003 */
/* (revised 21/1/2003, 14/2/2003, 2/5/2003, 2/7/2003, 3/2/2004, 8/5/2004, */
/* 1/2/2005, 3/2/2005) */
/* */
/* Department of Computer Science */
/* The University of Liverpool */
/* */
/* -------------------------------------------------------------------------- */
/* To compile: javac.exe AssocRuleMining.java */
// Java packages
import java.io.*;
import java.util.*;
// Java GUI packages
import javax.swing.*;
/** Set of utillities to support various Association Rule Mining (ARM)
algorithms.
@author Frans Coenen
@version 1 February 2005 */
public class AssocRuleMining extends JFrame {
/* ------ FIELDS ------ */
// Inner class for storing linked list of ARs or CARs as appropriate.
protected class RuleNode {
/** Antecedent of AR. */
protected short[] antecedent;
/** Consequent of AR. */
protected short[] consequent;
/** The confidence value associate with the rule represented by this
node. */
double confidenceForRule=0.0;
/** Link to next node */
RuleNode next = null;
/** Three argument constructor
@param ante the antecedent (LHS) of the AR.
@param cons the consequent (RHS) of the AR.
@param confValue the associated confidence value. */
protected RuleNode(short[] ante, short[]cons, double confValue) {
antecedent = ante;
consequent = cons;
confidenceForRule = confValue;
}
}
// Data structures
/** The reference to start of the rule list. */
protected RuleNode startRulelist = null;
/** 2-D aray to hold input data from data file. Note that within the data
array records are numbered from zero, thus rexcord one has index 0 etc. */
protected short[][] dataArray = null;
/** 2-D array used to renumber columns for input data in terms of
frequency of single attributes (reordering will enhance performance
for some ARM algorithms). */
protected int[][] conversionArray = null;
/** 1-D array used to reconvert input data column numbers to their
original numbering where the input data has been ordered to enhance
computational efficiency. */
protected short[] reconversionArray = null;
// Constants
/** Minimum support value */
private static final double MIN_SUPPORT = 0.0;
/** Maximum support value */
private static final double MAX_SUPPORT = 100.0;
/** Maximum confidence value */
private static final double MIN_CONFIDENCE = 0.0;
/** Maximum confidence value */
private static final double MAX_CONFIDENCE = 100.0;
// Command line arguments with default values and associated fields.
/** Command line argument for data file name. */
protected String fileName = null;
/** Command line argument for number of columns. */
protected int numCols = 0;
/** Command line argument for number of rows. */
protected int numRows = 0;
/** Command line argument for % support (default = 20%). */
protected double support = 20.0;
/** Minimum support value in terms of number of rows. <P>Set when input
data is read and the number of records is known, */
protected double minSupport = 0;
/** Command line argument for % confidence (default = 80%). */
protected double confidence = 80.0;
/** The number of one itemsets (singletons). */
protected int numOneItemSets = 0;
// Flags
/** Error flag used when checking command line arguments (default =
<TT>true</TT>). */
protected boolean errorFlag = true;
/** Input format OK flag( default = <TT>true</TT>). */
protected boolean inputFormatOkFlag = true;
/** Flag to indicate whether system has data or not. */
private boolean haveDataFlag = false;
/** Flag to indicate whether input data has been sorted or not. */
protected boolean isOrderedFlag = false;
/** Flag to indicate whether input data has been sorted and pruned or
not. */
protected boolean isPrunedFlag = false;
// Other fields
/** The input stream. */
protected BufferedReader fileInput;
/** The file path */
protected File filePath = null;
/* ------ CONSTRUCTORS ------ */
/** Processes command line arguments */
public AssocRuleMining(String[] args) {
// Process command line arguments
for(int index=0;index<args.length;index++) idArgument(args[index]);
// If command line arguments read successfully (errorFlag set to "true")
// check validity of arguments
if (errorFlag) CheckInputArguments();
else outputMenu();
}
/* ------ METHODS ------ */
/* ---------------------------------------------------------------- */
/* */
/* COMMAND LINE ARGUMENTS */
/* */
/* ---------------------------------------------------------------- */
/* IDENTIFY ARGUMENT */
/** Identifies nature of individual command line agruments:
-C = confidence, -F = file name, -S = support. */
protected void idArgument(String argument) {
if (argument.charAt(0) == '-') {
char flag = argument.charAt(1);
argument = argument.substring(2,argument.length());
switch (flag) {
case 'C':
confidence = Double.parseDouble(argument);
break;
case 'F':
fileName = argument;
break;
case 'S':
support = Double.parseDouble(argument);
break;
default:
System.out.println("INPUT ERROR: Unrecognise command " +
"line argument -" + flag + argument);
errorFlag = false;
}
}
else {
System.out.println("INPUT ERROR: All command line arguments " +
"must commence with a '-' character (" +
argument + ")");
errorFlag = false;
}
}
/* CHECK INPUT ARGUMENTS */
/** Invokes methods to check values associate with command line
arguments */
protected void CheckInputArguments() {
// Check support and confidence input
checkSupportAndConfidence();
// Check file name
checkFileName();
// Return
if (errorFlag) outputSettings();
else outputMenu();
}
/* CHECK SUPPORT AND CONFIDANCE */
/** Checks support and confidence input % values, if either is out of
bounds then <TT>errorFlag</TT> set to <TT>false</TT>. */
protected void checkSupportAndConfidence() {
// Check Support
if ((support < MIN_SUPPORT) || (support > MAX_SUPPORT)) {
System.out.println("INPUT ERROR: Support must be specified " +
"as a percentage (" + MIN_SUPPORT +
" - " + MAX_SUPPORT + ")");
errorFlag = false;
}
// Check confidence
if ((confidence < MIN_CONFIDENCE) || (confidence > MAX_CONFIDENCE)) {
System.out.println("INPUT ERROR: Confidence must be " +
"specified as a
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
85375530fp-tree-java.rar (6个子文件)
fp-tree java
TtreeNode.java 2KB
TotalSupportTree.java 23KB
AssocRuleMining.java 52KB
FPgrowthApp.java 2KB
FPtree.java 38KB
www.pudn.com.txt 218B
共 6 条
- 1
资源评论
- lhklp1232013-02-26代码写的很详细。就是注释都是英文的。有点看不明白
- Angoul2014-12-04时间有点长了,记得注释挺规范,要细看才能理解
msl1121
- 粉丝: 18
- 资源: 51
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功