public class MyDataset
extends java.lang.Object
Class to implement the dataset
Modifier and Type | Field and Description |
---|---|
protected java.util.Vector |
attributes
The attributes.
|
protected int |
classIndex
The index of the class attribute.
|
protected InstanceSet |
IS
Keel dataset InstanceSet
|
protected java.util.Vector |
itemsets
The itemsets.
|
protected java.lang.String |
name
The name of the dataset.
|
Constructor and Description |
---|
MyDataset(MyDataset dataset)
Constructor that copies another dataset.
|
MyDataset(MyDataset dataset,
int capacity)
Constructor to copy all the attributes of another dataset but the itemsets.
|
MyDataset(java.lang.String name,
boolean train)
Function to read the .dat file that contains the information of the dataset.
|
Modifier and Type | Method and Description |
---|---|
void |
addItemset(Itemset itemset)
Function to add one itemset.
|
java.lang.String[] |
classify(Mask actives,
Ruleset[] rulesets,
int length)
Classifies the entries' classes according to several sets of rules.
|
java.lang.String[] |
classify(Mask actives,
java.util.Vector rules)
Classifies the entries' classes according to several rules.
|
java.lang.String[] |
classify(Ruleset[] rulesets,
int length)
Classifies the entries' classes according to several sets of rules.
|
java.lang.String[] |
classify(java.util.Vector rules)
Classifies the entries' classes according to several rules.
|
java.lang.String |
copyHeader()
It copies the header of the dataset
|
void |
delete(int index)
Function to remove an itemset at the given position.
|
void |
deleteWithMissing(int attIndex)
Function to remove all the attributes with missing value in the given attribute.
|
java.util.Enumeration |
enumerateAttributes()
Enumerates all the attributes.
|
java.util.Enumeration |
enumerateItemsets()
Enumerates all the itemsets.
|
void |
filter(Mask mask,
int A,
double V,
int operator)
It filters the instances covered by a simple rule from this dataset;
i.e., it deactivates the instances not covered by that rule.
|
void |
filter(Mask mask,
Rule rule)
It filters the instances covered by a rule from this dataset;
i.e., it deactivates the instances not covered by that rule.
|
void |
filter(Mask mask,
Ruleset rules)
It filters the instances covered by a set of rule from this dataset;
i.e., it deactivates the instances not covered by that ruleset.
|
void |
filter(Mask mask,
Ruleset rules,
int ignore)
It filters the instances covered by a set of rule from this dataset;
i.e., it deactivates the instances not covered by that ruleset.
|
void |
filter(Mask mask,
SimpleRule sr)
It filters the instances covered by a simple rule from this dataset;
i.e., it deactivates the instances not covered by that rule.
|
void |
filterByClass(Mask mask,
java.lang.String class_name)
It filters the instances of a given class from this dataset;
i.e., it deactivates the instances from the other class.
|
MyAttribute |
getAttribute(int index)
Returns the attribute that has the index.
|
MyAttribute |
getAttribute(java.lang.String name)
Returns the attribute that has the name.
|
MyAttribute |
getClassAttribute()
Returns class attribute.
|
int[] |
getClassFequency()
Returns the frequency (number of instances) of each class.
|
int[] |
getClassFequency(Mask filter)
Returns the frequency (number of instances) of each class.
|
int |
getClassIndex()
Returns the index of the class attribute.
|
double |
getEntropy()
Returns the class entropy of this set.
|
double |
getEntropy(Mask filter)
Returns the class entropy of this set.
|
double[] |
getExample(int pos)
Output a specific example
|
double[] |
getExample(Mask mask)
Output a specific example
|
java.lang.String |
getMostFrequentClass()
Returns the most frequent class.
|
java.lang.String |
getName()
Returns the name of the dataset.
|
boolean |
isMissing(int exemple,
int attribute)
It returns wether the value for an attribute in a given exemple is missing
|
boolean |
isMissing(Mask mask,
int attribute)
It returns wether the value for an attribute in a given exemple is missing
|
Itemset |
itemset(int index)
Returns the itemset at the given position.
|
Itemset |
lastItemset()
Returns the last itemset.
|
int |
numAttributes()
Returns the number of attributes.
|
int |
numClasses()
Returns the number of possible values of the class attribute.
|
int |
numItemsets()
Returns the number of itemsets.
|
int |
size()
It returns the number of exemple of the dataset
|
void |
sort(int attIndex)
Function to sort the dataset based on an attribute.
|
MyDataset[] |
split(Rule r)
It split phisically the itemsets into two subdatasets,
according to the coverage of a rule.
|
void |
substract(Mask mask,
int A,
double V,
int operator)
It substracts the instances covered by a simple rule from this dataset;
i.e., it deactivates the instances covered by that rule.
|
void |
substract(Mask mask,
Rule rule)
It substracts the instances covered by a rule from this dataset;
i.e., it deactivates the instances covered by that rule.
|
void |
substract(Mask mask,
Ruleset rules)
It substracts the instances covered by a set of rule from this dataset;
i.e., it deactivates the instances covered by that ruleset.
|
void |
substract(Mask mask,
Ruleset rules,
int ignore)
It substracts the instances covered by a set of rules from this dataset;
i.e., it deactivates the instances covered by that ruleset.
|
void |
substract(Mask mask,
SimpleRule sr)
It substracts the instances covered by a simple rule from this dataset;
i.e., it deactivates the instances covered by that rule.
|
double |
sumOfWeights()
Function to compute the sum of all the weights of the itemsets.
|
java.lang.String |
toString()
Returns a string representation of the entries of this MyDataset.
|
java.lang.String |
toString(keel.Algorithms.Genetic_Rule_Learning.PART.IncrementalMask mask)
Returns a string representation of the active entries of this MyDataset.
|
java.lang.String |
toString(Mask mask)
Returns a string representation of the active entries of this MyDataset.
|
protected java.lang.String name
protected java.util.Vector attributes
protected java.util.Vector itemsets
protected int classIndex
protected InstanceSet IS
public MyDataset(java.lang.String name, boolean train)
name
- The reader object where the itemsets are readed.train
- The flag if the file is for trainingpublic MyDataset(MyDataset dataset)
dataset
- The dataset to be copied.public MyDataset(MyDataset dataset, int capacity)
dataset
- The dataset to be copied.capacity
- The number of itemsets.public final void addItemset(Itemset itemset)
itemset
- The itemset to add to the dataset.public java.lang.String getName()
public final MyAttribute getAttribute(int index)
index
- int The index of the attribute.public final MyAttribute getAttribute(java.lang.String name)
name
- String The name of the attribute.public final MyAttribute getClassAttribute()
public final int getClassIndex()
public final int numAttributes()
public final int numClasses()
public final int numItemsets()
public final void delete(int index)
index
- The index of the itemset to be deleted.public final void deleteWithMissing(int attIndex)
attIndex
- The index of the attribute.public java.util.Enumeration enumerateAttributes()
public final java.util.Enumeration enumerateItemsets()
public final Itemset itemset(int index)
index
- The index of the itemset.public final Itemset lastItemset()
public final double sumOfWeights()
public final void sort(int attIndex)
attIndex
- The index of the attribute.public void filter(Mask mask, int A, double V, int operator)
mask
- Mask the mask with the active entries of the datasetA
- int attribute's idV
- double attribute's valueoperator
- int rule operator. It could be: Rule.EQUAL(for discret attributes),
Rule.GREATER (>) or Rule.LOWER(<=)public void filter(Mask mask, SimpleRule sr)
mask
- Mask the mask with the actives entries of the datasetsr
- SimpleRule the rulepublic void filter(Mask mask, Rule rule)
mask
- Mask the mask with the active entries of the datasetrule
- Rule the rulepublic void filter(Mask mask, Ruleset rules)
mask
- Mask the mask with the active entries of the datasetrules
- Ruleset the rulesetpublic void filter(Mask mask, Ruleset rules, int ignore)
mask
- Mask the mask with the active entries of the datasetrules
- Ruleset the rulesetignore
- int the algorithm ignores the i-th rule of the rulesetpublic void filterByClass(Mask mask, java.lang.String class_name)
mask
- Mask the mask whit the active entries of the datasetclass_name
- String the name of the classpublic void substract(Mask mask, int A, double V, int operator)
mask
- Mask the mask with the active entries of the datasetA
- int attribute's idV
- double attribute's valueoperator
- int rule operator. It could be: Rule.EQUAL(for discret attributes),
Rule.GREATER (>) or Rule.LOWER(<=)public void substract(Mask mask, SimpleRule sr)
mask
- Mask the mask with the active entries of the datasetsr
- SimpleRule the rulepublic void substract(Mask mask, Rule rule)
mask
- Mask the mask with the active entries of the datasetrule
- Rule the rulepublic void substract(Mask mask, Ruleset rules)
mask
- Mask the mask with the active entries of the datasetrules
- Ruleset the set of rulespublic void substract(Mask mask, Ruleset rules, int ignore)
mask
- Mask the mask with the active entries of the datasetrules
- Ruleset the set of rulesignore
- int number of the rule to ignorepublic MyDataset[] split(Rule r)
r
- the rulepublic java.lang.String[] classify(Mask actives, Ruleset[] rulesets, int length)
actives
- Mask active entries of the datasetrulesets
- Ruleset[] the rulesetslength
- int the number of rulesetspublic java.lang.String[] classify(Mask actives, java.util.Vector rules)
actives
- Mask active entries of the datasetrules
- Vector the rules vectorpublic boolean isMissing(int exemple, int attribute)
exemple
- int index of the exemple in the datasetattribute
- int index of the attributepublic boolean isMissing(Mask mask, int attribute)
mask
- Mask the index of the mask signs the given exempleattribute
- int index of the attributepublic int size()
public java.lang.String[] classify(Ruleset[] rulesets, int length)
rulesets
- Ruleset[] the rulesetslength
- int the number of rulesetspublic java.lang.String[] classify(java.util.Vector rules)
rules
- Vector the rules vectorpublic double[] getExample(int pos)
pos
- int position (id) of the example in the data-setpublic double[] getExample(Mask mask)
mask
- Mask with the position (id) of the example in the data-setpublic int[] getClassFequency()
public java.lang.String getMostFrequentClass()
public int[] getClassFequency(Mask filter)
filter
- Mask filterpublic double getEntropy()
public double getEntropy(Mask filter)
filter
- Mask only active entries.public java.lang.String copyHeader()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(Mask mask)
mask
- Mask active entriespublic java.lang.String toString(keel.Algorithms.Genetic_Rule_Learning.PART.IncrementalMask mask)
mask
- IncrementalMask active entries