public class Rule
extends java.lang.Object
implements java.lang.Comparable
Title: Rule
Description: Fuzzy Rule in the GP-COACH algorithm
Company: KEEL
| Constructor and Description |
|---|
Rule()
Default constructor
|
Rule(DataBase database,
int n_classes,
int tnorm,
int tconorm,
int rule_weight)
Constructor with parameters.
|
Rule(DataBase database,
int n_classes,
int tnorm,
int tconorm,
int rule_weight,
double[] sample,
int sample_class)
Constructor with parameters.
|
Rule(Rule original)
Copy constructor for a Fuzzy rule from another Fuzzy Rule
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLabel(int variable_mutated,
DataBase data,
int low_granularity)
Adds a label to the fuzzy antecedent of the given variable
|
void |
addVar(DataBase data,
int low_granularity)
Adds a new variable to the fuzzy antecedent set of this rule
|
void |
changeLabel(int variable_mutated,
DataBase data,
int low_granularity)
Changes a label in the fuzzy antecedent of the given variable from an existing value to a
non-existing value
|
void |
clearAntecedent()
Deletes all the data stored in this rule antecedent
|
int |
compareTo(java.lang.Object a)
Compares this object with the specified object for order, according to the raw_fitness measure
|
double |
compatibility(double[] sample,
boolean[] missing)
Computes the compatibility degree of the rule with an input example.
|
double |
computeLocalHierarchicalMeasure(myDataset dataset,
double min_matching_degree)
Computes the local hierarchical measure for this rule, according to the matching degree given for samples
|
boolean |
containsEqualAntecedents(Rule r)
Compares this rule with the specified rule to check if the rules have the same antecedents
|
void |
deleteLabel(int variable_mutated,
int low_granularity)
Deletes a label to the fuzzy antecedent of the given variable
|
void |
deleteVar(int low_granularity)
Deletes a variable from the fuzzy antecedent set of this rule
|
boolean |
equals(java.lang.Object o)
Compares this rule with another rule to check if both rules are equal
|
void |
evaluate(myDataset dataset,
double alpha)
Evaluates this rule, computing the raw_fitness of the rule
and the weight.
|
void |
exchangeAntecedentLabel(int pos_att_to_change,
FuzzyAntecedent var,
DataBase data,
int low_granularity)
Changes the antecedent labels for one condition in the antecedent to
another labels in the antecedent
|
void |
exchangeVariables(boolean[] current_variables,
java.util.ArrayList<FuzzyAntecedent> new_variables,
int low_granularity)
Changes the antecedent labels for one condition in the antecedent to
another labels in the antecedent
|
int |
getClas()
Obtains the class associated to this rule, consequent of the fuzzy rule
|
double |
getFitness()
Obtains the fitness associated to this rule, its raw_fitness measure
|
double |
getGranularity()
Obtains the granularity of this rule as the maximum number of labels that a fuzzy antecedent can have
|
int |
getLevel()
Obtains the level of this rule; 1 for general rules, 2 for specific rules
|
double |
getLocalHierarchicalMeasure()
Obtains the local hierarchical measure associated to this rule, computed with the compute hierarchical measures procedure
|
int |
getnCond()
Obtains the number of different conditions used in this rule antecedent
|
int |
getnVar()
Obtains the number of variables used in this rule antecedent
|
double |
getPenalizedFitness()
Obtains the penalized fitness associated to this rule, computed with the token competition procedure
|
int |
getSeizedSamples()
Computes the number of training samples that match this rule.
|
FuzzyAntecedent |
getVar(int i)
Obtains the ith variable used in this rule antecedent
|
double |
getWeight()
Obtains the weight associated to this rule
|
int |
hashCode()
Computes the hash code associated to the current rule
|
int |
ideal()
Computes the number of training samples that match this rule and are correctly classified.
|
boolean |
isSeized(int idSample)
Checks if a determined value of the training set is seized by this rule or not
|
boolean |
not_eval()
Checks if the current rule has been evaluated or not.
|
java.lang.String |
printString(java.lang.String[] names,
java.lang.String[] classes)
String representation of a Fuzzy Rule in the GP-COACH-H algorithm.
|
void |
setClass(int new_class,
int low_granularity)
Changes the class of the rule to a new specified class.
|
void |
setLocalHierarchicalMeasure(double measure)
Sets the local hierarchical measure field to a specified given value, corresponding to this rule local hierarchical
measure according to the data set and the other rules considered
|
void |
setPenalizedFitness(double fitness)
Sets the penalized fitness field to a specified given value, corresponding to this rule penalized
fitness according to the data set and the other rules considered
|
void |
updateFuzzyLabels(double[][] granularity_tuning,
myDataset dataset,
double alpha)
Updates the current rule according to a specified lateral tuning of the associated fuzzy labels
|
public Rule()
public Rule(DataBase database, int n_classes, int tnorm, int tconorm, int rule_weight)
database - Data Base associated to the general rule base that includes this rulen_classes - Number of classes in the training settnorm - T-norm used to compute the compatibility degreetconorm - T-conorm used to compute the compatibility degreerule_weight - Rule weight of the created rulepublic Rule(DataBase database, int n_classes, int tnorm, int tconorm, int rule_weight, double[] sample, int sample_class)
database - Data Base associated to the general rule base that includes this rulen_classes - Number of classes in the training settnorm - T-norm used to compute the compatibility degreetconorm - T-conorm used to compute the compatibility degreerule_weight - Rule weight of the created rulesample - Data sample used to generate this rulesample_class - Output class associated to the data sample used to generate this rulepublic Rule(Rule original)
original - Rule which will be used as base to create another Rulepublic boolean not_eval()
public void evaluate(myDataset dataset, double alpha)
dataset - Training dataset used in this algorithmalpha - Alpha of the raw_fitness evaluation functionpublic double compatibility(double[] sample,
boolean[] missing)
sample - The input examplemissing - An array with the missing values for this input examplepublic double getWeight()
public int getClas()
public int getLevel()
public int getnVar()
public int getnCond()
public double getFitness()
public void setClass(int new_class,
int low_granularity)
new_class - class that is going to be assigned to this rulelow_granularity - number of labels that indicate low granularity for a rulepublic FuzzyAntecedent getVar(int i)
i - variable position we want to extract from the antecedentpublic void exchangeAntecedentLabel(int pos_att_to_change,
FuzzyAntecedent var,
DataBase data,
int low_granularity)
pos_att_to_change - position in this rule antecedent of the attribute that
is going to change labelsvar - fuzzy antecedent containing the new label for the selected attributedata - Data Base associated to the general rule base that includes this rulelow_granularity - number of labels that indicate low granularity for a rulepublic void exchangeVariables(boolean[] current_variables,
java.util.ArrayList<FuzzyAntecedent> new_variables,
int low_granularity)
current_variables - boolean array with the selected variables from this rulenew_variables - ArrayList of FuzzyAntecedent that contains the new variables for this rulelow_granularity - number of labels that indicate low granularity for a rulepublic void addLabel(int variable_mutated,
DataBase data,
int low_granularity)
variable_mutated - position of the variable that is going to have a label addeddata - Data Base associated to the general rule base that includes this rulelow_granularity - number of labels that indicate low granularity for a rulepublic void deleteLabel(int variable_mutated,
int low_granularity)
variable_mutated - position of the variable that is going to have a label deletedlow_granularity - number of labels that indicate low granularity for a rulepublic void changeLabel(int variable_mutated,
DataBase data,
int low_granularity)
variable_mutated - position of the variable that is going to have a label deleteddata - Data Base associated to the general rule base that includes this rulelow_granularity - number of labels that indicate low granularity for a rulepublic void clearAntecedent()
public void addVar(DataBase data, int low_granularity)
data - Data Base associated to the general rule base that includes this rulelow_granularity - number of labels that indicate low granularity for a rulepublic void deleteVar(int low_granularity)
low_granularity - number of labels that indicate low granularity for a rulepublic int ideal()
public int getSeizedSamples()
public void setPenalizedFitness(double fitness)
fitness - penalized fitness value associated to this rulepublic boolean isSeized(int idSample)
idSample - Position in the training set of the value that we want to seize with this rulepublic double getPenalizedFitness()
public double getGranularity()
public void setLocalHierarchicalMeasure(double measure)
measure - local hierarchical measure associated to this rulepublic double getLocalHierarchicalMeasure()
public double computeLocalHierarchicalMeasure(myDataset dataset, double min_matching_degree)
dataset - Training dataset used in this algorithmmin_matching_degree - Minimum compatibility degree that the rule must have with the sample to be considered as a matching samplepublic boolean containsEqualAntecedents(Rule r)
r - Rule that is going to be compared with the current rulepublic void updateFuzzyLabels(double[][] granularity_tuning,
myDataset dataset,
double alpha)
granularity_tuning - Lateral tuning of the associated fuzzy labels of this ruledataset - Training dataset used in this algorithmalpha - Alpha of the raw_fitness evaluation functionpublic int compareTo(java.lang.Object a)
compareTo in interface java.lang.Comparablea - object to compare with.public boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - Rule that is going to be compared with the current rulepublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String printString(java.lang.String[] names,
java.lang.String[] classes)
names - attributes names.classes - classes considered.