public class Rule
extends java.lang.Object
Representation of a string of simple rules chained by 'and's: exemple[a1][=|>|<=]v1 && exemple[a2][=|>=|<=]v2
Modifier and Type | Field and Description |
---|---|
static int |
EQUAL
Flag for equal operator
|
static int |
GREATER
Flag for greater operator
|
static int |
LOWER
Flag for lower operator
|
Constructor and Description |
---|
Rule()
Constructs an empty rule.
|
Modifier and Type | Method and Description |
---|---|
int |
apply(MyDataset data)
It returns the number of the instances covered by the rule in a given dataset
|
int |
apply(MyDataset data,
Mask select)
Returns the number of the instances covered by the rule in a given dataset
|
int |
apply(MyDataset data,
Mask select,
int ignore)
Returns the number of the instances covered by the rule in a given dataset.
|
keel.Algorithms.Rule_Learning.C45RulesSA.Stats |
apply(MyDataset data,
Mask positives,
Mask negatives)
It returns the number of true positives,true negatives,false positives and false negatives of the rule in a given dataset
|
static double |
biased(double N,
double E,
double ExpE)
Biased function.
|
Rule |
getCopy()
It returns a copy of this rule
|
static double |
getExceptionCost(MyDataset data,
int tp,
int tn,
int fp,
int fn)
Static version.
|
double |
getExceptionCost(MyDataset data,
Mask positives,
Mask negatives)
Returns the Minimum Data Length of a dataset given a theory (this rule).
|
SimpleRule |
getSimpleRule(int i)
Returns the i-ieth simple rule of this rule.
|
java.lang.String |
getType()
It returns the right side (class) of the rule.
|
void |
grow(int attribute,
double value,
int operator)
Adds a simple rule to this rule.
|
void |
grow(SimpleRule sr)
Adds a simple rule to this rule.
|
boolean |
isEqual(Rule r)
Return wether this rule is equal to another given rule
|
void |
prune(int pos)
Deletes a simple rule from this chain
|
void |
setType(java.lang.String new_class)
It sets the right side of the rule.
|
int |
size()
Returns the size (number of simple rules) of the rule
|
static double |
subsetDL(double t,
double k,
double p)
Subset description length:
S(t,k,p) = -k*log2(p)-(n-k)log2(1-p) Details see Quilan: "MDL and categorical theories (Continued)",ML95 |
double |
theoryDL(MyDataset data)
The description length of the theory for a given rule.
|
java.lang.String |
toString()
Returns a string representation of this Rule, containing the String representation of each SimpleRule.
|
public static int GREATER
public static int LOWER
public static int EQUAL
public int apply(MyDataset data, Mask select, int ignore)
data
- MyDataset the datasetselect
- Mask the mask with the active entries of the datasetignore
- int id of the single rule that it will be ignore in the applying of the rulepublic int apply(MyDataset data, Mask select)
data
- MyDataset the datasetselect
- Mask the mask with the active entries of the datasetpublic int apply(MyDataset data)
data
- MyDataset the datasetpublic keel.Algorithms.Rule_Learning.C45RulesSA.Stats apply(MyDataset data, Mask positives, Mask negatives)
data
- MyDataset the datasetpositives
- active positive instances of datanegatives
- active negative instances of datapublic double getExceptionCost(MyDataset data, Mask positives, Mask negatives)
data
- MyDataset the datasetspositives
- Mask active positive entries of datanegatives
- Mask active negative entries of datapublic static double getExceptionCost(MyDataset data, int tp, int tn, int fp, int fn)
data
- MyDataset the datasetstp
- int true positivestn
- int true negativesfp
- int false positivesfn
- int false negativespublic static double biased(double N, double E, double ExpE)
N
- N parameter given.E
- E parameter given.ExpE
- exponent given.public static double subsetDL(double t, double k, double p)
t
- the number of elements in a known setk
- the number of elements in a subsetp
- the expected proportion of subset known by recipientpublic double theoryDL(MyDataset data)
Details see Quilan: "MDL and categorical theories (Continued)",ML95
data
- MyDataset the datasetpublic SimpleRule getSimpleRule(int i)
i
- position of the simple rulepublic void grow(int attribute, double value, int operator)
attribute
- int attribute id (position of the attribute)value
- double attribute's valueoperator
- int rule operatorpublic void grow(SimpleRule sr)
sr
- SimpleRule the simple rulepublic void setType(java.lang.String new_class)
new_class
- double new class of the rulepublic java.lang.String getType()
public Rule getCopy()
public void prune(int pos)
pos
- int position of the simple rule of the rulepublic int size()
public boolean isEqual(Rule r)
r
- Rule the given rulepublic java.lang.String toString()
toString
in class java.lang.Object