|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--milk.core.Exemplars
The class of a set of exemplars
| Constructor Summary | |
Exemplars(Exemplars exemplars)
Constructor to form an Exemplars by deep copying from another Exemplars |
|
Exemplars(Exemplars exemplars,
int size)
Constructor creating an empty Exemplars with the same structure of the given Exemplars and the given size (i.e. |
|
Exemplars(Exemplars source,
int first,
int toCopy)
Creates a new set of instances by copying a subset of another set. |
|
Exemplars(weka.core.Instances dataset)
Constructor using the given dataset and set ID index to 0 |
|
Exemplars(weka.core.Instances dataset,
int idIndex)
Constructor using the given dataset and set ID index to the given ID index. |
|
| Method Summary | |
void |
add(Exemplar exemplar)
Adds one exemplar to the exemplars |
void |
add(weka.core.Instance instance)
Adds one instance to one of the exemplars |
weka.core.Attribute |
attribute(int index)
Returns an attribute. |
weka.core.Attribute |
attribute(java.lang.String name)
Returns an attribute given its name. |
boolean |
checkForStringAttributes()
Checks for string attributes in the Exemplars |
weka.core.Attribute |
classAttribute()
Returns the class attribute. |
int |
classIndex()
Returns the class attribute's index. |
void |
compactify()
Compactifies each exemplar in this Exemplars |
void |
delete()
Removes all Exemplars from the set. |
void |
delete(int index)
Removes an exemplar at the given position from the set. |
void |
deleteAttributeAt(int position)
Deletes an attribute at the given position (0 to numAttributes() - 1). |
void |
deleteStringAttributes()
Deletes all string attributes in the dataset. |
void |
deleteWithMissing(weka.core.Attribute att)
Removes all instances with missing values for a particular attribute from the dataset. |
void |
deleteWithMissing(int attIndex)
Removes all instances with missing values for a particular attribute from the dataset. |
java.util.Enumeration |
enumerateAttributes()
Returns an enumeration of all the attributes. |
Exemplar |
exemplar(int index)
Returns the exemplar at the given position. |
Exemplar |
firstExemplar()
Returns the first exemplar in the set. |
java.util.Vector |
getExemplars()
Returns a vector of exemplars in this Exemplars. |
weka.core.Attribute |
idAttribute()
Returns the ID attribute. |
int |
idIndex()
Returns the ID attribute's index. |
void |
insertAttributeAt(weka.core.Attribute att,
int position)
Inserts an attribute at the given position (0 to numAttributes()) and sets all values to be missing. |
Exemplar |
lastExemplar()
Returns the last exemplar in the set. |
static void |
main(java.lang.String[] args)
Main method for this class -- just performone run of 10-fold CV and prints out the set. |
int |
numAttributes()
Returns the number of attributes. |
int |
numClasses()
Returns the number of class labels. |
int |
numExemplars()
Returns the number of exemplars in the set. |
int[] |
numsInstances()
Returns the number of instances in the dataset. |
void |
randomize(java.util.Random random)
Shuffles the exemplars in the set so that they are ordered randomly. |
java.lang.String |
relationName()
Returns the relation's name. |
void |
renameAttribute(weka.core.Attribute att,
java.lang.String name)
Renames an attribute. |
void |
renameAttribute(int att,
java.lang.String name)
Renames an attribute. |
void |
renameAttributeValue(weka.core.Attribute att,
java.lang.String val,
java.lang.String name)
Renames the value of a nominal (or string) attribute value. |
void |
renameAttributeValue(int att,
int val,
java.lang.String name)
Renames the value of a nominal (or string) attribute value. |
Exemplars |
resample(java.util.Random random)
Creates a new Exemplars of the same size using random sampling with replacement. |
Exemplars |
resampleWithWeights(java.util.Random random)
Creates a new Exemplars of the same size using random sampling with replacement according to the current exemplar weights. |
Exemplars |
resampleWithWeights(java.util.Random random,
double[] weights)
Creates a new dataset of the same size using random sampling with replacement according to the given weight vector. |
void |
setRelationName(java.lang.String newName)
Sets the relation's name. |
void |
sort()
Sorts the instances based on the ID attribute. |
void |
stratify(int numFolds)
Stratifies a set of exemplars according to its class values if the class attribute is nominal (so that afterwards a stratified cross-validation can be performed). |
double[] |
sumsOfWeights()
Computes the sum of all the exemplars' weights. |
Exemplars |
testCV(int numFolds,
int numFold)
Creates the test set for one fold of a cross-validation on the dataset. |
java.lang.String |
toString()
Returns the exemplars as a string. |
Exemplars |
trainCV(int numFolds,
int numFold)
Creates the training set skipping for one fold of a cross-validation on the exemplar set. |
Exemplars |
trainCV(int numFolds,
int numFold,
java.util.Random random)
Creates the training set for one fold of a cross-validation on the dataset. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Exemplars(Exemplars exemplars)
exemplars - the copied Exemplars
public Exemplars(Exemplars exemplars,
int size)
exemplars - the given Exemplarssize - the given size
public Exemplars(weka.core.Instances dataset)
throws java.lang.Exception
dataset - the set to be copied
java.lang.Exception - if the class index of the dataset
is not set(i.e. -1)
public Exemplars(Exemplars source,
int first,
int toCopy)
source - the set of instances from which a subset
is to be createdfirst - the index of the first instance to be copiedtoCopy - the number of instances to be copied
java.lang.IllegalArgumentException - if first and toCopy are out of range
public Exemplars(weka.core.Instances dataset,
int idIndex)
throws java.lang.Exception
dataset - the instances from which the header
information is to be takenidIndex - the ID attribute's index
java.lang.Exception - if the class index of the dataset
is not set(i.e. -1) or the data is not a multi-instance data| Method Detail |
public final void add(weka.core.Instance instance)
instance - the instance to be added
java.lang.Exception - if the instance cannot be added properlypublic final void add(Exemplar exemplar)
exemplar - the exemplar to be added
java.lang.Exception - if the exemplar already existspublic final weka.core.Attribute attribute(int index)
index - the attribute's index
public final weka.core.Attribute attribute(java.lang.String name)
name - the attribute's name
public boolean checkForStringAttributes()
public final weka.core.Attribute classAttribute()
weka.core.UnassignedClassException - if the class is not setpublic final int classIndex()
public final void compactify()
public final void delete()
public final void delete(int index)
index - the instance's position
public void deleteAttributeAt(int position)
throws java.lang.Exception
java.lang.Exception - if the given index is out of range or the
class attribute is being deleted
public void deleteStringAttributes()
throws java.lang.Exception
java.lang.IllegalArgumentException - if string attribute couldn't be
successfully deleted (probably because it is the class attribute).
java.lang.Exceptionpublic final void deleteWithMissing(int attIndex)
attIndex - the attribute's indexpublic final void deleteWithMissing(weka.core.Attribute att)
att - the attributepublic java.util.Enumeration enumerateAttributes()
public final java.util.Vector getExemplars()
public final Exemplar firstExemplar()
public final weka.core.Attribute idAttribute()
public final int idIndex()
public void insertAttributeAt(weka.core.Attribute att,
int position)
att - the attribute to be inserted
java.lang.IllegalArgumentException - if the given index is out of rangepublic final Exemplar exemplar(int index)
index - the exemplar's index
public final Exemplar lastExemplar()
public final int numAttributes()
public final int numClasses()
weka.core.UnassignedClassException - if the class is not setpublic final int numExemplars()
public final int[] numsInstances()
public final void randomize(java.util.Random random)
random - a random number generatorpublic final java.lang.String relationName()
public final void renameAttribute(int att,
java.lang.String name)
att - the attribute's indexname - the new name
public final void renameAttribute(weka.core.Attribute att,
java.lang.String name)
att - the attributename - the new name
public final void renameAttributeValue(int att,
int val,
java.lang.String name)
att - the attribute's indexval - the value's indexname - the new name
public final void renameAttributeValue(weka.core.Attribute att,
java.lang.String val,
java.lang.String name)
att - the attributeval - the valuename - the new namepublic final Exemplars resample(java.util.Random random)
random - a random number generator
public final Exemplars resampleWithWeights(java.util.Random random)
throws java.lang.Exception
random - a random number generator
java.lang.Exception - if the weights array is of the wrong
length or contains negative weights or
any other errors related to exemplars.
public final Exemplars resampleWithWeights(java.util.Random random,
double[] weights)
throws java.lang.Exception
random - a random number generatorweights - the weight vector
java.lang.Exception - if the weights array is of the wrong
length or contains negative weights or
any other errors related to exemplars.public final void setRelationName(java.lang.String newName)
newName - the new relation name.public final void sort()
public final void stratify(int numFolds)
numFolds - the number of folds in the cross-validation
weka.core.UnassignedClassException - if the class is not setpublic final double[] sumsOfWeights()
public Exemplars testCV(int numFolds,
int numFold)
throws java.lang.Exception
numFolds - the number of folds in the cross-validation. Must
be greater than 1.numFold - 0 for the first fold, 1 for the second, ...
java.lang.Exception - if the number of folds is less than 2
or greater than the number of exemplars
or any other errors related to exemplar occurpublic final java.lang.String toString()
toString in class java.lang.Object
public Exemplars trainCV(int numFolds,
int numFold)
throws java.lang.Exception
numFolds - the number of folds in the cross-validation. Must
be greater than 1.numFold - 0 for the first fold, 1 for the second, ...
java.lang.Exception - if the number of folds is less than 2
or greater than the number of exemplars or
or any other errors related to exemplar occur.
public Exemplars trainCV(int numFolds,
int numFold,
java.util.Random random)
throws java.lang.Exception
numFolds - the number of folds in the cross-validation. Must
be greater than 1.numFold - 0 for the first fold, 1 for the second, ...random - the random number generator
java.lang.IllegalArgumentException - if the number of folds is less than 2
or greater than the number of instances.
java.lang.Exceptionpublic static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||