public class AssocRuleMining
extends javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
Modifier and Type | Field and Description |
---|---|
protected double |
confidence
Command line argument for % confidence (default = 80%).
|
protected int[][] |
conversionArray
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 short[][] |
dataArray
2-D aray to hold input data from data file
|
protected boolean |
errorFlag
Error flag used when checking command line arguments (default =
true).
|
protected java.io.BufferedReader |
fileInput
The input stream.
|
protected java.lang.String |
fileName
Command line argument for data file name.
|
protected java.io.File |
filePath
The file path
|
protected boolean |
inputFormatOkFlag
Input format OK flag( default = true).
|
protected double |
minSupport
Minimum support value in terms of number of rows.
|
protected int |
numCols
Command line argument for number of columns.
|
protected int |
numOneItemSets
The number of one itemsets (singletons).
|
protected int |
numRows
Command line argument for number of rows.
|
protected short[] |
reconversionArray
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 double |
support
Command line argument for % support (default = 20%).
|
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Constructor and Description |
---|
AssocRuleMining()
Default constructor used in particular when creating an isnatnce of the
class RuleList which is a subclass of theAssocRuleMining class.
|
AssocRuleMining(java.lang.String[] args)
Processes command line arguments
|
Modifier and Type | Method and Description |
---|---|
protected short[] |
append(short[] itemSet1,
short[] itemSet2)
Concatenates two itemSets --- resizes given array so that its length is
increased by size of second array and second array added.
|
protected short[] |
binConversion(java.util.StringTokenizer dataLine,
int numberOfTokens)
Produce an item set (array of elements) from input line.
|
protected void |
checkFileName()
Checks if data file name provided, if not errorFlag set to
false.
|
protected void |
CheckInputArguments()
Invokes methods to check values associate with command line arguments
|
protected void |
checkLine(int counter,
java.lang.String str)
Check whether given line from input file is of appropriate format (space
separated integers), if incorrectly formatted line found
inputFormatOkFlag set to false.
|
protected boolean |
checkOrdering()
Checks that data set is ordered correctly.
|
protected void |
checkSupportAndConfidence()
Checks support and confidence input % values, if either is out of bounds
then errorFlag set to false.
|
protected void |
closeFile()
Close file fileName (instance field).
|
protected short[][] |
combinations(short[] inputSet)
Invokes combinations method to calculate all possible
combinations of a given item set.
|
protected short[] |
complement(short[] itemSet1,
short[] itemSet2)
Returns complement of first itemset with respect to second itemset.
|
protected short[] |
copyItemSet(short[] itemSet)
Makes a copy of a given itemSet.
|
protected void |
countNumCols()
Counts number of columns represented by input data.
|
protected int[][] |
countSingles()
Counts number of occurrences of each single attribute in the input data.
|
protected void |
defConvertArrays(int[][] countArray)
Defines conversion and reconversion arrays.
|
double |
getConfidence()
Gets the current confidence setting.
|
protected java.lang.String |
getDuration(double time1,
double time2)
Returns the difference between two given times as a string.
|
protected int |
getNumberOfLines(java.lang.String nameOfFile)
Gets number of lines/records in input file and checks format of each
line.
|
protected int |
getNumSupOneItemSets()
Gets number of supported single item sets (note this is not necessarily
the same as the number of columns/attributes in the input set).
|
protected void |
idArgument(java.lang.String argument)
Identifies nature of individual command line agruments: -C = confidence,
-F = file name, -S = support.
|
void |
idInputDataOrdering()
Reorders input data according to frequency of single attributes.
|
void |
inputDataSet()
Commences process of getting input data (GUI version also exists).
|
protected boolean |
notMemberOf(short number,
short[] itemSet)
Checks whether a particular element/attribute identified by a column
number is not a member of the given item set.
|
protected void |
openFileName(java.lang.String nameOfFile)
Opens file using fileName (instance field).
|
protected void |
orderFirstNofCountArray(int[][] countArray,
int endIndex)
Bubble sorts first N elements in count array produced by
countSingles method so that array is ordered according to
frequency of single items.
|
double |
outputDuration(double time1,
double time2)
Outputs difference between two given times.
|
protected void |
outputItemSet(short[] itemSet)
Outputs a given item set.
|
protected void |
outputItemSetWithReconversion(short[] itemSet)
Outputs a given item set reconverting it to its original column number
labels (used where input dataset has been reordered and possible pruned).
|
protected void |
outputMenu()
Outputs menu for command line arguments.
|
protected void |
outputSettings()
Outputs command line values provided by user.
|
void |
readFile()
Reads input data from file specified in command line argument (GUI
version also exists).
|
void |
readInputDataSet()
Reads input data from file specified in command line argument.
|
protected short[] |
realloc1(short[] oldItemSet,
short newElement)
Resizes given item set so that its length is increased by one and appends
new element (identical to append method)
|
protected short[] |
realloc2(short[] oldItemSet,
short newElement)
Resizes given array so that its length is increased by one element and
new element added to front
|
protected short[] |
reallocInsert(short[] oldItemSet,
short newElement)
Resizes given item set so that its length is increased by one and new
element inserted.
|
void |
recastInputData()
Recasts the contents of the data array so that each record is ordered
according to conversion array.
|
void |
recastInputDataAndPruneUnsupportedAtts()
Recasts the contents of the data array so that each record is ordered
according to ColumnCounts array and excludes non-supported elements.
|
protected short[] |
removeFirstNelements(short[] oldItemSet,
int n)
Removes the first n elements/attributes from the given item set.
|
void |
resizeInputData(double percentage)
Recasts the input data sets so that only N percent is used.
|
void |
setFileName(java.lang.String fileName) |
protected void |
sortItemSet(short[] itemSet)
Sorts an unordered item set.
|
protected double |
twoDecPlaces(double number)
Converts given real number to real number rounded up to two decimal
places.
|
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected short[][] dataArray
protected int[][] conversionArray
protected short[] reconversionArray
protected java.lang.String fileName
protected int numCols
protected int numRows
protected double support
protected double minSupport
protected double confidence
protected int numOneItemSets
protected boolean errorFlag
protected boolean inputFormatOkFlag
protected java.io.BufferedReader fileInput
protected java.io.File filePath
public AssocRuleMining(java.lang.String[] args)
public AssocRuleMining()
protected void idArgument(java.lang.String argument)
protected void CheckInputArguments()
protected void checkSupportAndConfidence()
protected void checkFileName()
public void inputDataSet()
public void readFile()
Proceeds as follows:
protected int getNumberOfLines(java.lang.String nameOfFile) throws java.io.IOException
nameOfFile
- the filename of the file to be opened.java.io.IOException
protected void checkLine(int counter, java.lang.String str)
counter
- the line number in the input file.str
- the current line from the input file.public void readInputDataSet() throws java.io.IOException
java.io.IOException
protected boolean checkOrdering()
protected void countNumCols()
protected void openFileName(java.lang.String nameOfFile)
nameOfFile
- the filename of the file to be opened.protected void closeFile()
protected short[] binConversion(java.util.StringTokenizer dataLine, int numberOfTokens)
dataLine
- row from the input data filenumberOfTokens
- number of items in rowpublic void idInputDataOrdering()
Example, given the data set:
1 2 5 1 2 3 2 4 5 1 2 5 2 3 5This would produce a countArray (ignore index 0):
+---+---+---+---+---+---+ | | 1 | 2 | 3 | 4 | 5 | +---+---+---+---+---+---+ | | 3 | 5 | 2 | 1 | 4 | +---+---+---+---+---+---+Which sorts to:
+---+---+---+---+---+---+ | | 2 | 5 | 1 | 3 | 4 | +---+---+---+---+---+---+ | | 5 | 4 | 3 | 2 | 1 | +---+---+---+---+---+---+Giving rise to the conversion Array of the form (no index 0):
+---+---+---+---+---+---+ | | 3 | 1 | 4 | 5 | 2 | +---+---+---+---+---+---+ | | 3 | 5 | 2 | 1 | 4 | +---+---+---+---+---+---+Note that the second row here are the counts which no longer play a role in the conversion exercise. Thus to the new column number for column 1 is column 3 (i.e. the first vale at index 1). The reconversion array of the form:
+---+---+---+---+---+---+ | | 2 | 5 | 1 | 3 | 4 | +---+---+---+---+---+---+
protected int[][] countSingles()
protected void orderFirstNofCountArray(int[][] countArray, int endIndex)
Used when ordering classification input data.
countArray
- The 2-D array returned by the countSingles method.endIndex
- the index of the Nth element.protected void defConvertArrays(int[][] countArray)
countArray
- The 2-D array sorted by the orderCcountArray method.public void recastInputData()
Proceed as follows: 1) For each record in the data array. Create an empty new itemSet array. 2) Place into this array attribute/column numbers that correspond to the appropriate equivalents contained in the conversion array. 3) Reorder this itemSet and return into the data array.
public void recastInputDataAndPruneUnsupportedAtts()
Proceed as follows: 1) For each record in the data array. Create an empty new itemSet array. 2) Place into this array any column numbers in record that are supported at the index contained in the conversion array. 3) Assign new itemSet back into to data array
protected int getNumSupOneItemSets()
public void resizeInputData(double percentage)
percentage
- the percentage of the current input data that is to form the
new input data set (number between 0 and 100).protected short[] append(short[] itemSet1, short[] itemSet2)
itemSet1
- The first item set.itemSet2
- The item set to be appended.protected short[] reallocInsert(short[] oldItemSet, short newElement)
oldItemSet
- the original item setnewElement
- the new element/attribute to be insertedprotected short[] realloc1(short[] oldItemSet, short newElement)
oldItemSet
- the original item setnewElement
- the new element/attribute to be appendedprotected short[] realloc2(short[] oldItemSet, short newElement)
oldItemSet
- the original item setnewElement
- the new element/attribute to be appendedprotected short[] removeFirstNelements(short[] oldItemSet, int n)
oldItemSet
- the given item set.n
- the number of leading elements to be removed.protected short[] complement(short[] itemSet1, short[] itemSet2)
itemSet1
- the first given item set.itemSet2
- the second given item set.protected void sortItemSet(short[] itemSet)
itemSet
- the given item set.protected boolean notMemberOf(short number, short[] itemSet)
number
- the attribute identifier (column number).itemSet
- the given item set.protected short[][] combinations(short[] inputSet)
For example given the item set [1,2,3] this will result in the combinations[[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]].
inputSet
- the given item set.protected short[] copyItemSet(short[] itemSet)
itemSet
- the given item set.public double getConfidence()
protected void outputMenu()
protected void outputSettings()
protected void outputItemSet(short[] itemSet)
itemSet
- the given item set.protected void outputItemSetWithReconversion(short[] itemSet)
itemSet
- the given item set.public double outputDuration(double time1, double time2)
time1
- the first time.time2
- the second time.protected java.lang.String getDuration(double time1, double time2)
time1
- the first time.time2
- the second time.protected double twoDecPlaces(double number)
number
- the given number.public void setFileName(java.lang.String fileName)