public class RuleBase
extends java.lang.Object
Title: RuleBase
Description: This class contains the representation of a Rule Set
Copyright: Copyright KEEL (c) 2007
Company: KEEL
Constructor and Description |
---|
RuleBase()
Default Constructor.
|
RuleBase(DataBase dataBase,
myDataset train,
int K,
int typeInference)
Builder
|
Modifier and Type | Method and Description |
---|---|
void |
add(Itemset itemset)
It adds a rule to the rule base
|
void |
add(Rule rule)
It adds a rule to the rule base
|
void |
add(RuleBase ruleBase)
It adds the rules of the RuleBase given.
|
boolean |
BETTER(int a,
int b)
Maximization
|
void |
clear()
Removes the rules stored.
|
RuleBase |
clone()
Clone
|
void |
evaluate()
Function to evaluate the whole rule base by using the training dataset.
|
void |
evaluate(double[] gene,
int[] selected)
Function to evaluate the selected rules by using the training dataset and the fuzzy functions stored in the gene given.
|
int |
FRM(double[] example)
Predicts the class value for a given example, using the rules and type of inference stored on the RuleBase.
|
int |
FRM(double[] example,
int[] selected)
Predicts the class value for a given example, using the selected rules and type of inference stored on the RuleBase.
|
Rule |
get(int pos)
Function to get a rule from the rule base
|
double |
getAccuracy()
Function to return the fitness of the rule base
|
int |
getK()
Returns the value of the parameter K.
|
int |
getTypeInference()
Returns the type of inference used to build the rules.
|
int |
getUncover()
Returns the number of examples uncovered by the rules
|
int |
hasClassUncovered(int[] selected)
Indentifies how many classes are uncovered with a selection of rules.
|
boolean |
hasUncover()
Checks if there are examples uncovered by the rules.
|
java.lang.String |
printString()
It prints the whole rulebase
|
void |
reduceRules(int clas)
Function to eliminate the rules that are not needed (Redundant, not enough accurate,...) for a given class.
|
Rule |
remove(int pos)
It removes the rule stored in the given position
|
void |
saveFile(java.lang.String filename)
It stores the rule base in a given file
|
void |
setDefaultRule()
Sets the default rule.
|
int |
size()
It returns the number of rules in the rule base
|
void |
sort()
Function to sort the rule base
|
public RuleBase()
public RuleBase(DataBase dataBase, myDataset train, int K, int typeInference)
Builder
dataBase
- Data Basetrain
- Training datasetK
- Covered patterns in the second stage are completely eliminated when they have been covered more than K times.typeInference
- Two option: 0) the class of the rule with the best matching; 1) the class with the best matchingpublic boolean BETTER(int a, int b)
a
- first numberb
- second numberpublic RuleBase clone()
Clone
clone
in class java.lang.Object
public void add(Rule rule)
It adds a rule to the rule base
rule
- Rule to be addedpublic void add(RuleBase ruleBase)
It adds the rules of the RuleBase given.
ruleBase
- Rules to be addedpublic void add(Itemset itemset)
It adds a rule to the rule base
itemset
- itemset to be addedpublic Rule get(int pos)
Function to get a rule from the rule base
pos
- Position in the rule base where the desired rule is storedpublic int size()
It returns the number of rules in the rule base
public void sort()
Function to sort the rule base
public Rule remove(int pos)
It removes the rule stored in the given position
pos
- Position where the rule we want to remove ispublic void clear()
public int getTypeInference()
public double getAccuracy()
Function to return the fitness of the rule base
public void setDefaultRule()
public boolean hasUncover()
public int getUncover()
public int getK()
public void evaluate()
public void evaluate(double[] gene, int[] selected)
gene
- Representation where the fuzzy functions needed to evaluate are storedselected
- Selection of rules to be evaluatedpublic int FRM(double[] example)
example
- Example to be predicted.public int FRM(double[] example, int[] selected)
example
- Example to be predicted.selected
- Selection of rules to be considered for the class prediction.public int hasClassUncovered(int[] selected)
selected
- rules selected to be testedpublic void reduceRules(int clas)
clas
- class whose rules are being testedpublic java.lang.String printString()
It prints the whole rulebase
public void saveFile(java.lang.String filename)
It stores the rule base in a given file
filename
- Name for the rulebase file