Package weka.associations
Class PredictiveApriori
- java.lang.Object
-
- weka.associations.AbstractAssociator
-
- weka.associations.PredictiveApriori
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Associator
,CARuleMiner
,CapabilitiesHandler
,OptionHandler
,RevisionHandler
,TechnicalInformationHandler
public class PredictiveApriori extends AbstractAssociator implements OptionHandler, CARuleMiner, TechnicalInformationHandler
Class implementing the predictive apriori algorithm to mine association rules.
It searches with an increasing support threshold for the best 'n' rules concerning a support-based corrected confidence value.
For more information see:
Tobias Scheffer: Finding Association Rules That Trade Support Optimally against Confidence. In: 5th European Conference on Principles of Data Mining and Knowledge Discovery, 424-435, 2001.
The implementation follows the paper expect for adding a rule to the output of the 'n' best rules. A rule is added if:
the expected predictive accuracy of this rule is among the 'n' best and it is not subsumed by a rule with at least the same expected predictive accuracy (out of an unpublished manuscript from T. Scheffer). BibTeX:@inproceedings{Scheffer2001, author = {Tobias Scheffer}, booktitle = {5th European Conference on Principles of Data Mining and Knowledge Discovery}, pages = {424-435}, publisher = {Springer}, title = {Finding Association Rules That Trade Support Optimally against Confidence}, year = {2001} }
Valid options are:-N <required number of rules output> The required number of rules. (default = 100)
-A If set class association rules are mined. (default = no)
-c <the class index> The class index. (default = last)
- Version:
- $Revision: 6365 $
- Author:
- Stefan Mutter (mutter@cs.waikato.ac.nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PredictiveApriori()
Constructor that allows to sets default values for the minimum confidence and the maximum number of rules the minimum confidence.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildAssociations(Instances instances)
Method that generates all large itemsets with a minimum support, and from these all association rules.java.lang.String
carTipText()
Returns the tip text for this propertyjava.lang.String
classIndexTipText()
Returns the tip text for this propertyFastVector[]
getAllTheRules()
returns all the rulesCapabilities
getCapabilities()
Returns default capabilities of the classifier.boolean
getCar()
Gets whether class association ruels are minedint
getClassIndex()
Gets the index of the class attributeInstances
getInstancesNoClass()
Gets the instances without the class attributeInstances
getInstancesOnlyClass()
Gets the class attribute of all instancesint
getNumRules()
Get the value of the number of required rules.java.lang.String[]
getOptions()
Gets the current settings of the PredictiveApriori object.java.lang.String
getRevision()
Returns the revision string.TechnicalInformation
getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.java.lang.String
globalInfo()
Returns a string describing this associatorjava.util.Enumeration
listOptions()
Returns an enumeration describing the available options.static void
main(java.lang.String[] args)
Main method.java.lang.String
metricString()
Returns the metric string for the chosen metric type.FastVector[]
mineCARs(Instances data)
Method that mines the n best class association rules.java.lang.String
numRulesTipText()
Returns the tip text for this propertyvoid
resetOptions()
Resets the options to the default values.void
setCar(boolean flag)
Sets class association rule miningvoid
setClassIndex(int index)
Sets the class indexvoid
setNumRules(int v)
Set the value of required rules.void
setOptions(java.lang.String[] options)
Parses a given list of options.java.lang.String
toString()
Outputs the association rules.-
Methods inherited from class weka.associations.AbstractAssociator
forName, makeCopies, makeCopy
-
-
-
-
Method Detail
-
globalInfo
public java.lang.String globalInfo()
Returns a string describing this associator- Returns:
- a description of the evaluator suitable for displaying in the explorer/experimenter gui
-
getTechnicalInformation
public TechnicalInformation getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.- Specified by:
getTechnicalInformation
in interfaceTechnicalInformationHandler
- Returns:
- the technical information about this class
-
resetOptions
public void resetOptions()
Resets the options to the default values.
-
getCapabilities
public Capabilities getCapabilities()
Returns default capabilities of the classifier.- Specified by:
getCapabilities
in interfaceAssociator
- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Overrides:
getCapabilities
in classAbstractAssociator
- Returns:
- the capabilities of this classifier
- See Also:
Capabilities
-
buildAssociations
public void buildAssociations(Instances instances) throws java.lang.Exception
Method that generates all large itemsets with a minimum support, and from these all association rules.- Specified by:
buildAssociations
in interfaceAssociator
- Parameters:
instances
- the instances to be used for generating the associations- Throws:
java.lang.Exception
- if rules can't be built successfully
-
mineCARs
public FastVector[] mineCARs(Instances data) throws java.lang.Exception
Method that mines the n best class association rules.- Specified by:
mineCARs
in interfaceCARuleMiner
- Parameters:
data
- the instances for which class association rules should be mined- Returns:
- an sorted array of FastVector (depending on the expected predictive accuracy) containing the rules and metric information
- Throws:
java.lang.Exception
- if rules can't be built successfully
-
getInstancesNoClass
public Instances getInstancesNoClass()
Gets the instances without the class attribute- Specified by:
getInstancesNoClass
in interfaceCARuleMiner
- Returns:
- instances without class attribute
-
getInstancesOnlyClass
public Instances getInstancesOnlyClass()
Gets the class attribute of all instances- Specified by:
getInstancesOnlyClass
in interfaceCARuleMiner
- Returns:
- Instances containing only the class attribute
-
listOptions
public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceOptionHandler
- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(java.lang.String[] options) throws java.lang.Exception
Parses a given list of options. Valid options are:-N <required number of rules output> The required number of rules. (default = 100)
-A If set class association rules are mined. (default = no)
-c <the class index> The class index. (default = last)
- Specified by:
setOptions
in interfaceOptionHandler
- Parameters:
options
- the list of options as an array of strings- Throws:
java.lang.Exception
- if an option is not supported
-
getOptions
public java.lang.String[] getOptions()
Gets the current settings of the PredictiveApriori object.- Specified by:
getOptions
in interfaceOptionHandler
- Returns:
- an array of strings suitable for passing to setOptions
-
toString
public java.lang.String toString()
Outputs the association rules.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of the model
-
numRulesTipText
public java.lang.String numRulesTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getNumRules
public int getNumRules()
Get the value of the number of required rules.- Returns:
- Value of the number of required rules.
-
setNumRules
public void setNumRules(int v)
Set the value of required rules.- Parameters:
v
- Value to assign to number of required rules.
-
setClassIndex
public void setClassIndex(int index)
Sets the class index- Specified by:
setClassIndex
in interfaceCARuleMiner
- Parameters:
index
- the index of the class attribute
-
getClassIndex
public int getClassIndex()
Gets the index of the class attribute- Returns:
- the index of the class attribute
-
classIndexTipText
public java.lang.String classIndexTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setCar
public void setCar(boolean flag)
Sets class association rule mining- Parameters:
flag
- if class association rules are mined, false otherwise
-
getCar
public boolean getCar()
Gets whether class association ruels are mined- Returns:
- true if class association rules are mined, false otherwise
-
carTipText
public java.lang.String carTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
metricString
public java.lang.String metricString()
Returns the metric string for the chosen metric type. Predictive apriori uses the estimated predictive accuracy. Therefore the metric string is "acc".- Specified by:
metricString
in interfaceCARuleMiner
- Returns:
- string "acc"
-
getAllTheRules
public FastVector[] getAllTheRules()
returns all the rules- Returns:
- all the rules
- See Also:
m_allTheRules
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classAbstractAssociator
- Returns:
- the revision
-
main
public static void main(java.lang.String[] args)
Main method.- Parameters:
args
- the commandline parameters
-
-