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)
Adds a label to the fuzzy antecedent of the given variable
|
void |
addVar(DataBase data)
Adds a new variable to the fuzzy antecedent set of this rule
|
void |
changeLabel(int variable_mutated,
DataBase data)
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.
|
void |
deleteLabel(int variable_mutated)
Deletes a label to the fuzzy antecedent of the given variable
|
void |
deleteVar()
Deletes a variable from the fuzzy antecedent set of this rule
|
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)
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)
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
|
int |
getLevel()
Obtains the level of this rule; 1 for general rules, 2 for specific rules
|
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
|
FuzzyAntecedent |
getVar(int i)
Obtains the ith variable used in this rule antecedent
|
double |
getWeight()
Obtains the weight associated to this rule
|
int |
ideal()
Computes the number of training samples that match this rule.
|
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 algorithm.
|
void |
setClass(int new_class)
Changes the class of the rule to a new specified class.
|
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
|
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
- Way of computing the rule weightpublic 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
- Way of computing the rule weightsample
- 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)
new_class
- class that is going to be assigned to this 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)
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 rulepublic void exchangeVariables(boolean[] current_variables, java.util.ArrayList<FuzzyAntecedent> new_variables)
current_variables
- boolean array with the selected variables from this rulenew_variables
- ArrayList of FuzzyAntecedent that contains the new variables for this rulepublic void addLabel(int variable_mutated, DataBase data)
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 rulepublic void deleteLabel(int variable_mutated)
variable_mutated
- position of the variable that is going to have a label deletedpublic void changeLabel(int variable_mutated, DataBase data)
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 rulepublic void clearAntecedent()
public void addVar(DataBase data)
data
- Data Base associated to the general rule base that includes this rulepublic void deleteVar()
public int ideal()
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 int compareTo(java.lang.Object a)
compareTo
in interface java.lang.Comparable
a
- Object to compare with.public java.lang.String printString(java.lang.String[] names, java.lang.String[] classes)
names
- names of the different attributes.classes
- values of classes as Strings.