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 = 50%).
|
protected int[][] |
conversionArray
2-D array used to renumber coulmns 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 aruments (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 |
numClasses
Number of classes in input data set (input by the user).
|
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 efficienvy.
|
protected double |
support
Command line argument for % support (default = 1%).
|
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.
|
AssocRuleMining(double minConf,
double minSup)
Processes command line arguments.
|
Modifier and Type | Method and Description |
---|---|
protected short[] |
append(short[] itemSet1,
short[] itemSet2)
Concatinates 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 short[] |
checkForLeadingSubString(short[] itemSet1,
short[] itemSet2)
Checks whether two itemSets share a leading substring.
|
protected int |
checkItemSets(short[] itemSet1,
short[] itemSet2)
Determines relationship between two item sets (same, parent,
before, child or after).
|
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 short[][] |
copyItemSet(short[][] itemSets)
Makes a copy of a given set of itemSets.
|
protected int[][] |
countSingles(DataBase dataBase)
Counts number of occurances 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 short |
getLastElement(short[] itemSet)
Gets the last element in the given item set, or '0' if the itemset is
empty.
|
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).
|
void |
idInputDataOrdering(DataBase dataBase)
Reorders input data according to frequency of
single attributes.
|
void |
inputDataSet(myDataset train,
DataBase dataBase)
Commences process of getting inout data (GUI version also exists).
|
static boolean |
isBefore(short[] itemSet1,
short[] itemSet2)
Checks whether one item set is lexicographically before a second
item set.
|
protected boolean |
isEqual(short[] itemSet1,
short[] itemSet2)
Checks whether two item sets are the same.
|
protected boolean |
isSubset(short[] itemSet1,
short[] itemSet2)
Checks whether one item set is subset of a second item set.
|
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 |
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.
|
void |
outputConversionArrays()
Outputs conversion array (used to renumber coulmns for input data
in terms of frequency of single attributes --- reordering will enhance
performance for some ARM algorithms).
|
void |
outputDataArray()
Outputs stored input data set; initially read from input data file, but
may be reirdered or pruned if desired by a particular application.
|
protected void |
outputDataArray(short[][] dataSet)
Outputs the given array of array of short integers.
|
void |
outputDataArraySize()
Ouputs size (number of records and number of elements) of stored
input data set read from input data file.
|
double |
outputDuration(double time1,
double time2)
Outputs difference between two given times.
|
protected java.lang.String |
outputItemSet(short[] itemSet)
Outputs a given item set.
|
protected void |
outputItemSetWithReconversion(short[] itemSet)
Outputs a given item set reconverting it to its orginal 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.
|
protected void |
outputSettings2()
Outputs instance field values.
|
void |
outputSuppAndConf()
Outputs current support and confidence settings.
|
void |
readFile(myDataset train,
DataBase dataBase)
Reads input data from file specified in command line argument (GUI
version also exists).
|
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[] |
realloc3(short[] oldItemSet)
Resizes given array so that its length is decreased by one element
and first element removed
|
protected short[] |
realloc4(short[] oldItemSet,
short[] array2)
Resize given array so that its length is decreased by size of
second array (which is expected to be a leading subset of the first)
and remove second array.
|
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.
|
protected boolean |
similar2dec(double number1,
double number2)
Compares two real numbers and returns true if the two numbers are
the same within two decimal places.
|
protected void |
sortItemSet(short[] itemSet)
Sorts an unordered item set.
|
protected double |
threeDecPlaces(double number)
Converts given real number to real number rounded up to three decimal
places.
|
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 int numClasses
protected boolean errorFlag
protected boolean inputFormatOkFlag
protected java.io.BufferedReader fileInput
protected java.io.File filePath
public AssocRuleMining(double minConf, double minSup)
minConf
- double Minimum confidence thresholdminSup
- double Minimum support thresholdpublic AssocRuleMining()
public void inputDataSet(myDataset train, DataBase dataBase)
train
- myDataset Class where examples are stored to build the classifierdataBase
- DataBase Class to store the examples to work with the algorithm and some other useful informationpublic void readFile(myDataset train, DataBase dataBase)
Proceeds as follows:
train
- myDataset Class where examples are stored to build the classifierdataBase
- DataBase Class to store the examples to work with the algorithm and some other useful informationprotected short[] binConversion(java.util.StringTokenizer dataLine, int numberOfTokens)
dataLine
- row from the input data filenumberOfTokens
- number of items in rowpublic void idInputDataOrdering(DataBase dataBase)
Example, giben 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 | +---+---+---+---+---+---+
dataBase
- DataBase Class to store the examples to work with the algorithm and some other useful informationprotected int[][] countSingles(DataBase dataBase)
dataBase
- object where the examples to work with the algorithm and some other useful information are stored.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 orderCountArray
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 coorospond 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[] realloc3(short[] oldItemSet)
oldItemSet
- the original item setprotected short[] realloc4(short[] oldItemSet, short[] array2)
oldItemSet
- The first item set.array2
- The leading subset of the oldItemSet.protected short[] removeFirstNelements(short[] oldItemSet, int n)
oldItemSet
- the given item set.n
- the number of leading elements to be removed.protected short getLastElement(short[] itemSet)
itemSet
- the given item set.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 int checkItemSets(short[] itemSet1, short[] itemSet2)
itemSet1
- the first item set.itemSet2
- the second item set to be compared with first.protected boolean isEqual(short[] itemSet1, short[] itemSet2)
itemSet1
- the first item set.itemSet2
- the second item set to be compared with first.public static boolean isBefore(short[] itemSet1, short[] itemSet2)
itemSet1
- the first item set.itemSet2
- the second item set to be compared with first.protected boolean isSubset(short[] itemSet1, short[] itemSet2)
itemSet1
- the first item set.itemSet2
- the second item set to be compared with first.protected boolean notMemberOf(short number, short[] itemSet)
number
- the attribute identifier (column number).itemSet
- the given item set.protected short[] checkForLeadingSubString(short[] itemSet1, short[] itemSet2)
itemSet1
- the first item set.itemSet2
- the second item set to be compared with first.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.protected short[][] copyItemSet(short[][] itemSets)
itemSets
- the given set of item sets.public double getConfidence()
public void outputDataArray()
protected void outputDataArray(short[][] dataSet)
Used for diagnostic purposes.
dataSet
- the five array of arrays.protected java.lang.String outputItemSet(short[] itemSet)
itemSet
- the given item set.protected void outputItemSetWithReconversion(short[] itemSet)
itemSet
- the given item set.public void outputDataArraySize()
public void outputConversionArrays()
protected void outputMenu()
protected void outputSettings()
protected void outputSettings2()
public void outputSuppAndConf()
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 boolean similar2dec(double number1, double number2)
number1
- first given real number.number2
- second given number.protected double twoDecPlaces(double number)
number
- the given number.protected double threeDecPlaces(double number)
number
- the given number.