public class Ruleset
extends java.lang.Object
Representation of a disjuction of rules with a common consecuent. It may be represented as: if (rule1 || rule2) then output=consecuent Besides each rule has a positive value (confidence) associated. The entire ruleset has also a default rule whose confidence value must be always negative.
Constructor and Description |
---|
Ruleset()
Constructs an empty ruleset.
|
Modifier and Type | Method and Description |
---|---|
void |
addRule(Rule r)
Adds a new rule to the ruleset.
|
void |
addToDefaultCr(double Cr)
Adds a given value to the confidence of the default rule.
|
boolean |
contains(Rule r)
It returns wether a rule belongs to the ruleset
|
double |
getDefaultCr()
Returns the confidence of the default rule.
|
double |
getDefaultCr(MyDataset data,
Mask positives,
Mask negatives,
double[] distribution)
Computes the confidence of the default rule, according to the equation 4
of [AAAI99]:
Cr=1/2ln((W+ + 1/(2n))/(W_ + 1/(2n)))
W+: sum of the weights of the positive instances that are covered by the current rule
W_: sum of the weights of the negative instances that are covered by the current rule
n: |p|+|n|
|
Rule |
getRule(int pos)
Returns the rule in the i-th position of the ruleset.
|
java.lang.String |
getType()
Returns the common output (consecuent) of the rules in the ruleset.
|
int |
indexOf(Rule r)
It returns the position of a rule (if it is belongs to the ruleset)
|
void |
insertRule(Rule r,
int pos)
Inserts a new rule in a given position of the ruleset.
|
void |
removeRule(int pos)
Deletes a given rule of the ruleset.
|
void |
setType(java.lang.String type)
Sets the common output (consecuent) of the rules in the ruleset.
|
int |
size()
Returns the size (number of rules) of the ruleset.
|
java.lang.String |
toString()
Returns a string representation of this Ruleset, containing the String representation of each Rule.
|
public boolean contains(Rule r)
r
- Rule the simple rulepublic int indexOf(Rule r)
r
- Rule the simple rulepublic void addRule(Rule r)
r
- Rule the new rulepublic void addToDefaultCr(double Cr)
Cr
- the valuepublic double getDefaultCr(MyDataset data, Mask positives, Mask negatives, double[] distribution)
data
- MyDataset the datasetpositives
- Mask the positive entriesnegatives
- Mask the negative entriesdistribution
- double[] the distribution Dpublic double getDefaultCr()
public Rule getRule(int pos)
pos
- int position of the rule in the rulesetpublic java.lang.String getType()
public void insertRule(Rule r, int pos)
r
- Rule the new rulepos
- int the position where r must be insertedpublic void removeRule(int pos)
pos
- int position of the rule in the ruleset.public void setType(java.lang.String type)
type
- String the common output (consecuent) of the rules in the ruleset.public int size()
public java.lang.String toString()
toString
in class java.lang.Object