public class Rule
extends java.lang.Object
implements java.util.Comparator
Constructor and Description |
---|
Rule()
Default builder.
|
Rule(double[] instance,
int out)
Builder.
|
Modifier and Type | Method and Description |
---|---|
Rule |
clone()
Clone method
|
int |
compare(java.lang.Object o,
java.lang.Object o2)
Compare two rules, regarding its impurity level
|
static void |
computeDefaultImpurityLevels()
Computes the initial confidence intervals of the impurity levels of each class
|
void |
computeImpurityLevel()
Computes the impurity level of a rule
|
boolean |
contains(Rule another)
Test the rule contains a second rule
|
static void |
copyData(double[][] trainData,
int[] trainOutput)
Copies the training data iniside the class
|
double |
distance(double[] example)
Computes the distance between a rule and an instance
|
boolean |
equals(java.lang.Object rul)
Equals method
|
void |
generalizeContinuous(int att,
double value,
double percentage,
int out)
Generalizes a continuous attribute
|
void |
generalizeNominal(int att,
double value,
double percentage,
int out)
Generalizes a nominal attribute
|
double |
getImpurityLevel()
Returns the impurity level of a rule
|
int |
getOutput()
Returns the output class of the rule
|
double |
getSpecialImpurityLevel(Rule[] ruleset)
Computes the impurity level of a rule, by considering only those instances which are not already covered by other rules
|
double |
inclusionDegree(Rule another,
int att)
Computes the inclussion degree of two rules in a given attribute
|
boolean |
inside(double[] example)
Tests if an instance is covered by the rule
|
boolean |
intersect(Rule another)
Test if two rules intersects
|
void |
pruneConditions()
Prune redundant conditions of a rule, if it decreases its impurity level
|
double |
ruleDistance(Rule another)
Computes the distance between two rules
|
static void |
setAttributes(Attribute[] inputs)
Test which attributes are nominal
|
static void |
setNClasses(int value)
Sets the number of classes of the problem
|
static void |
setNInstances(int[] vector)
Sets the array of instances of each class
|
static void |
setNumValue(int value,
int pos)
Sets the number of different values for an attribute
|
static void |
setSize(int value)
Sets the size of the problem
|
Rule |
testExtension(Rule another)
Performs an extension of a rule to another
|
java.lang.String |
toString()
To String method
|
public Rule()
public Rule(double[] instance, int out)
instance
- Basic instanceout
- Ouput of the instancepublic static void setSize(int value)
value
- Number of attributes of the rulepublic static void setAttributes(Attribute[] inputs)
inputs
- Attributes' descriptionspublic static void setNumValue(int value, int pos)
value
- Number of valuespos
- Index of the attributepublic static void setNClasses(int value)
value
- Number of classespublic int getOutput()
public static void copyData(double[][] trainData, int[] trainOutput)
trainData
- training data Training datatrainOutput
- training output Output valuespublic static void setNInstances(int[] vector)
vector
- Array of instances of each classpublic static void computeDefaultImpurityLevels()
public double ruleDistance(Rule another)
another
- Second rulepublic double distance(double[] example)
example
- The instancepublic void generalizeContinuous(int att, double value, double percentage, int out)
att
- Attribute indexvalue
- Value to obtainpercentage
- Percentage of generalization allowedout
- Output class of the example to be coveredpublic void generalizeNominal(int att, double value, double percentage, int out)
att
- Attribute indexvalue
- Value to obtainpercentage
- Percentage of generalization allowedout
- Output class of the example to be coveredpublic void computeImpurityLevel()
public double getSpecialImpurityLevel(Rule[] ruleset)
ruleset
- other rules to cosider.public boolean inside(double[] example)
example
- Instance to be testedpublic double getImpurityLevel()
public Rule clone()
clone
in class java.lang.Object
public void pruneConditions()
public boolean intersect(Rule another)
another
- Second rule.public boolean contains(Rule another)
another
- Second rule.public double inclusionDegree(Rule another, int att)
another
- Second rule.att
- Attribute selectedpublic Rule testExtension(Rule another)
another
- Second rule.public boolean equals(java.lang.Object rul)
equals
in interface java.util.Comparator
equals
in class java.lang.Object
rul
- Another rulepublic java.lang.String toString()
toString
in class java.lang.Object
public int compare(java.lang.Object o, java.lang.Object o2)
compare
in interface java.util.Comparator
o
- First rule.o2
- Second rule.