Rule Class Reference

#include <Rule.h>

Collaboration diagram for Rule:
[legend]

List of all members.

Public Member Functions

 Rule ()
 Rule (int attribute, int value, Data *d, RULE_TYPE type, float(*scoreFnc)(Rule *)=NULL)
 ~Rule ()
void * getComponent ()
void setComponent (void *com)
std::vector< DisjunctionSet * > * getRuleSet ()
void setData (Data *d)
void setWeights (float alpha, float beta, float gamma)
float getScore ()
float getSupport ()
float getPD ()
float getPF ()
float getEffort ()
int getSize ()
Ruleclone ()
bool createFromFile (std::string fName, Data *d, RULE_TYPE type, float(*scoreFcn)(Rule *)=NULL)
float compare (Rule *r)
bool isSatisfied (std::vector< InstanceElement * > *instance)
void score ()
int findAttribute (int attribute)
int findAttributeValue (int attribute, int value)
bool hasComponent (int attribute, int value)
bool isEqualTo (Rule *r)
bool addComponent (int attribute, int value)
Rulecombine (Rule *r)
RulebackSelect ()
void printGotWant (std::ostream &stream, Data *eData)
void print (std::ostream &stream)
void printRule (std::ostream &stream)


Detailed Description

Represents a Rule for Which. Contains a series of attributes and the ranges they can have for a rule to fire. Rules in Which are a series of conjunctions of disjunctions. EG: ( a = 3 + a = 2 )( b = 9 + b = 5 )( ... )

Constructor & Destructor Documentation

Rule::Rule (  ) 

Creates an empty Rule. After this constructer the Rule will have no attributes to fire on.

Rule::Rule ( int  attribute,
int  value,
Data d,
RULE_TYPE  type,
float(*)(Rule *)  scoreFnc = NULL 
)

Creates a Rule with one conjunction.( if attribute = attributeValue then... )

Parameters:
attribute The numerical index of the attribute in the data set.
value The numerical index of the attribute's value in the data set.
d A pointer to the data set to score this Rule with.
type The type of Rule this is.
the method to use to score this rule. Only needed for type = SPECIAL

Rule::~Rule (  ) 

Destructor.


Member Function Documentation

void * Rule::getComponent (  ) 

Returns a pointer to the user defined component.

Returns:
The pointer.

void Rule::setComponent ( void *  com  ) 

Allows the user to create a class or struct that gets coupled with a Rule. Using this method allows the user to set a component of the Rule.

Parameters:
com A pointer to the component in memory.

vector< DisjunctionSet * > * Rule::getRuleSet (  ) 

Returns the Rule in toe form of a jagged array of integers. See DisjuctionSet to see how to use this array.

Returns:
A pointer to the Rule in a jagged array from.

void Rule::setData ( Data d  ) 

Allows the user to dynamically change the Data this Rule is evaluated on.

Parameters:
d The new Data.

void Rule::setWeights ( float  alpha,
float  beta,
float  gamma 
)

Allows the user to alter how the standard metrics of PD, PF, and Effort are weighted in any pre-defined scoring method that uses the above metrics.

Parameters:
alpha The weight of PD.
beta The weight of PF.
gamma The weight of Effort.

float Rule::getScore (  ) 

Gets the current score of a Rule.

Returns:
The score.

float Rule::getSupport (  ) 

Gets the current support of a Rule.

Returns:
The support.

float Rule::getPD (  ) 

Gets the PD of a Rule. This value is defined for all pre-defined scoring types.

Returns:
The PD.

float Rule::getPF (  ) 

Gets the PF of a Rule. This value is defined for all pre-defined scoring types.

Returns:
The PF.

float Rule::getEffort (  ) 

Gets the effort of a Rule. This value is defined for all pre-defined scoring types.

Returns:
The effort.

int Rule::getSize (  ) 

Gets the size of the Rule in terms of the sum of conjunctions and disjunctions. For instance: a=[1 OR 4 OR 5] AND b = [2 OR 5] has a size of 5

Returns:
The size.

Rule * Rule::clone (  ) 

Creates a cloned version of this Rule. The new Rule is completely seperate of this Rule.

Returns:
The newly cloned Rule.

bool Rule::createFromFile ( std::string  fName,
Data d,
RULE_TYPE  type,
float(*)(Rule *)  scoreFcn = NULL 
)

Creates a Rule from reading in a file.

Parameters:
fName The name of the file.
Data The data set to score and create this Rule with.
type The type of Rule this is.
the method to use to score this rule. Only needed for type = SPECIAL Returns false if no Rule was created. True otherwise.

float Rule::compare ( Rule r  ) 

Compares two Rules' scores.

Parameters:
r The Rule to compare to this one.
Returns:
>0 if r is greater than this Rule, 0 if r is equal to this Rule, <0 if r is less than this Rule.

bool Rule::isSatisfied ( std::vector< InstanceElement * > *  instance  ) 

Checks to see if an instance of data is satisfied by this Rule.

Parameters:
instance The instance of data.

void Rule::score (  ) 

Scores the Rule based on which type of Rule it is.

int Rule::findAttribute ( int  attribute  ) 

Checks to see if an attribute index is already in the Rule.

Parameters:
attribute The attribute index to search for.
Returns:
-1 if the attribute does not exist, the index of the attribute otherwise.

int Rule::findAttributeValue ( int  attribute,
int  value 
)

Checks to see if an attribute value is already in the Rule.

Parameters:
attribute The attribute whose value is to be searched for.
value The value of the attribute to search.
Returns:
-1 if the value is not found, the index of the value otherwise.

bool Rule::hasComponent ( int  attribute,
int  value 
)

Checks to see if a certain attribute value is in the Rule.

Parameters:
attribute The attribute index to check the value of.
value The value index of the attribute.
Returns:
True if it attribute = value is in this Rule, false otherwise.

bool Rule::isEqualTo ( Rule r  ) 

Checks to see if two Rules have the same component sets.

Parameters:
r The Rule to compare to this one.
Returns:
True if r == this, false otherwise.

bool Rule::addComponent ( int  attribute,
int  value 
)

Adds a new component to the Rule.

Parameters:
atribute The attribute to add.
vale The value of the attribute to add.
Returns:
True if it was added, false if it already was in the rule.

Rule * Rule::combine ( Rule r  ) 

Combines two Rules by adding together their disjunctions and conjunctions. If this Rule and r are equivalent, the new Rule is just a clone of the first rule.

Parameters:
r The Rule to add to this one.
Returns:
A pointer to a new Rule that is created from this one.

Rule * Rule::backSelect (  ) 

Attempts to create a better, smaller rule.

Returns:
The smaller rule.

void Rule::printGotWant ( std::ostream &  stream,
Data eData 
)

Prints a Weka-like got want matrix to allow for evaluation alongside the Weka.

Parameters:
stream The stream to print o.
eData The data containing the proper line of code information.

void Rule::print ( std::ostream &  stream  ) 

Prints the Rule in the format: A = [ 1 OR 2 ] AND B = [ 2 ] AND C = [ 1 OR 4 ] Score: ### <optional scoring="" metrics>="">

Parameters:
stream The stream to print the Rule to.

void Rule::printRule ( std::ostream &  stream  ) 

Prints just the Rule portion in the format. A = [ 1 OR 2 ] AND B = [ 2 ] AND C = [ 1 OR 4 ] => class

Parameters:
stream The stream to print tte Rule to.


The documentation for this class was generated from the following files:

Generated on Wed Feb 20 13:52:40 2008 for Which by  doxygen 1.5.5