|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectweka.core.AbstractHashableInstance
public abstract class AbstractHashableInstance
Ancestor for instance classes that wraps around any WEKA Instance
and allow them to be used in data structures that make use of on object's
hash, like maps or hashtables.
| Field Summary | |
|---|---|
protected weka.core.Instance |
m_Data
the wrapped instance. |
protected boolean |
m_ExcludeClass
whether to exclude the class from the hashcode. |
protected boolean |
m_ExcludeWeight
whether to exclude the weight from the hashcode. |
protected Integer |
m_HashCode
the current hashcode. |
| Constructor Summary | |
|---|---|
protected |
AbstractHashableInstance(weka.core.Instance data)
Initializes the wrapper. |
| Method Summary | |
|---|---|
protected void |
assign(AbstractHashableInstance inst)
Assigns all the data, apart from wrapped instance, that the provided hashable instance provides. |
weka.core.Attribute |
attribute(int index)
Returns the attribute with the given index. |
weka.core.Attribute |
attributeSparse(int indexOfIndex)
Returns the attribute with the given index in the sparse representation. |
weka.core.Attribute |
classAttribute()
Returns class attribute. |
int |
classIndex()
Returns the class attribute's index. |
boolean |
classIsMissing()
Tests if an instance's class is missing. |
double |
classValue()
Returns an instance's class value as a floating-point number. |
protected abstract int |
computeHashCode()
Computes the hashcode. |
Object |
copy()
This method produces a shallow copy of an object. |
weka.core.Instances |
dataset()
Returns the dataset this instance has access to. |
void |
deleteAttributeAt(int position)
Deletes an attribute at the given position (0 to numAttributes() - 1). |
Enumeration |
enumerateAttributes()
Returns an enumeration of all the attributes. |
boolean |
equalHeaders(weka.core.Instance inst)
Tests if the headers of two instances are equivalent. |
String |
equalHeadersMsg(weka.core.Instance inst)
Checks if the headers of two instances are equivalent. |
boolean |
equals(Object obj)
Returns only true if the same class and the same hashcode. |
boolean |
getExcludeClass()
Returns whether the class is excluded from the hashcode computation. |
boolean |
getExcludeWeight()
Returns whether the weight is excluded from the hashcode computation. |
int |
hashCode()
Returns the hashcode of this Instance, computes it if neccessary. |
boolean |
hasMissingValue()
Tests whether an instance has a missing value. |
int |
index(int position)
Returns the index of the attribute stored at the given position in the sparse representation. |
void |
insertAttributeAt(int position)
Inserts an attribute at the given position (0 to numAttributes()). |
protected void |
invalidateHashCode()
Invalidates the hash code. |
boolean |
isMissing(weka.core.Attribute att)
Tests if a specific value is "missing". |
boolean |
isMissing(int attIndex)
Tests if a specific value is "missing". |
boolean |
isMissingSparse(int indexOfIndex)
Tests if a specific value is "missing" in the sparse representation. |
weka.core.Instance |
mergeInstance(weka.core.Instance inst)
Merges this instance with the given instance and returns the result. |
int |
numAttributes()
Returns the number of attributes. |
int |
numClasses()
Returns the number of class labels. |
int |
numValues()
Returns the number of values present in a sparse representation. |
weka.core.Instances |
relationalValue(weka.core.Attribute att)
Returns the relational value of a relational attribute. |
weka.core.Instances |
relationalValue(int attIndex)
Returns the relational value of a relational attribute. |
void |
replaceMissingValues(double[] array)
Replaces all missing values in the instance with the values contained in the given array. |
void |
setClassMissing()
Sets the class value of an instance to be "missing". |
void |
setClassValue(double value)
Sets the class value of an instance to the given value (internal floating-point format). |
void |
setClassValue(String value)
Sets the class value of an instance to the given value. |
void |
setDataset(weka.core.Instances instances)
Sets the reference to the dataset. |
void |
setExcludeClass(boolean value)
Sets whether to exclude the class from the hashcode computation. |
void |
setExcludeWeight(boolean value)
Sets whether to exclude the weight from the hashcode computation. |
void |
setMissing(weka.core.Attribute att)
Sets a specific value to be "missing". |
void |
setMissing(int attIndex)
Sets a specific value to be "missing". |
void |
setValue(weka.core.Attribute att,
double value)
Sets a specific value in the instance to the given value (internal floating-point format). |
void |
setValue(weka.core.Attribute att,
String value)
Sets a value of an nominal or string attribute to the given value. |
void |
setValue(int attIndex,
double value)
Sets a specific value in the instance to the given value (internal floating-point format). |
void |
setValue(int attIndex,
String value)
Sets a value of a nominal or string attribute to the given value. |
void |
setValueSparse(int indexOfIndex,
double value)
Sets a specific value in the instance to the given value (internal floating-point format), given an index into the sparse representation. |
void |
setWeight(double weight)
Sets the weight of an instance. |
String |
stringValue(weka.core.Attribute att)
Returns the value of a nominal, string, date, or relational attribute for the instance as a string. |
String |
stringValue(int attIndex)
Returns the value of a nominal, string, date, or relational attribute for the instance as a string. |
double[] |
toDoubleArray()
Returns the values of each attribute as an array of doubles. |
String |
toString()
Returns the value of the Instance's toString() method. |
String |
toString(weka.core.Attribute att)
Returns the description of one value of the instance as a string. |
String |
toString(weka.core.Attribute att,
int afterDecimalPoint)
Returns the description of one value of the instance as a string. |
String |
toString(int attIndex)
Returns the description of one value of the instance as a string. |
String |
toString(int attIndex,
int afterDecimalPoint)
Returns the description of one value of the instance as a string. |
String |
toStringMaxDecimalDigits(int afterDecimalPoint)
Returns the description of one instance with any numeric values printed at the supplied maximum number of decimal places. |
String |
toStringNoWeight()
Returns the description of one instance (without weight appended). |
String |
toStringNoWeight(int afterDecimalPoint)
Returns the description of one instance (without weight appended). |
double |
value(weka.core.Attribute att)
Returns an instance's attribute value in internal format. |
double |
value(int attIndex)
Returns an instance's attribute value in internal format. |
double |
valueSparse(int indexOfIndex)
Returns an instance's attribute value in internal format, given an index in the sparse representation. |
double |
weight()
Returns the instance's weight. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Integer m_HashCode
protected weka.core.Instance m_Data
protected boolean m_ExcludeClass
protected boolean m_ExcludeWeight
| Constructor Detail |
|---|
protected AbstractHashableInstance(weka.core.Instance data)
data - the instance to wrap| Method Detail |
|---|
public Object copy()
copy in interface weka.core.Copyableprotected void assign(AbstractHashableInstance inst)
inst - the hashable instance to get the data frompublic weka.core.Attribute attribute(int index)
attribute in interface weka.core.Instanceindex - the attribute's index
UnassignedDatasetException - if instance doesn't have access to a
datasetpublic weka.core.Attribute attributeSparse(int indexOfIndex)
attributeSparse in interface weka.core.InstanceindexOfIndex - the index of the attribute's index
UnassignedDatasetException - if instance doesn't have access to a
datasetpublic weka.core.Attribute classAttribute()
classAttribute in interface weka.core.InstanceUnassignedDatasetException - if the class is not set or the instance
doesn't have access to a datasetpublic int classIndex()
classIndex in interface weka.core.InstanceUnassignedDatasetException - if instance doesn't have access to a
datasetpublic boolean classIsMissing()
classIsMissing in interface weka.core.InstanceUnassignedClassException - if the class is not set or the instance
doesn't have access to a datasetpublic double classValue()
classValue in interface weka.core.InstanceUnassignedClassException - if the class is not set or the instance
doesn't have access to a datasetpublic weka.core.Instances dataset()
dataset in interface weka.core.Instancepublic void deleteAttributeAt(int position)
deleteAttributeAt in interface weka.core.Instanceposition - the attribute's position
RuntimeException - if the instance has access to a datasetpublic Enumeration enumerateAttributes()
enumerateAttributes in interface weka.core.InstanceUnassignedDatasetException - if the instance doesn't have access to a
datasetpublic boolean equalHeaders(weka.core.Instance inst)
equalHeaders in interface weka.core.Instanceinst - another instance
UnassignedDatasetException - if instance doesn't have access to any
datasetpublic String equalHeadersMsg(weka.core.Instance inst)
equalHeadersMsg in interface weka.core.Instancedataset - another instance
public boolean hasMissingValue()
hasMissingValue in interface weka.core.InstanceUnassignedDatasetException - if instance doesn't have access to any
datasetpublic int index(int position)
index in interface weka.core.Instanceposition - the position
public void insertAttributeAt(int position)
insertAttributeAt in interface weka.core.Instanceposition - the attribute's position
RuntimeException - if the instance has accesss to a dataset
IllegalArgumentException - if the position is out of rangepublic boolean isMissing(int attIndex)
isMissing in interface weka.core.InstanceattIndex - the attribute's index
public boolean isMissing(weka.core.Attribute att)
isMissing in interface weka.core.Instanceatt - the attribute
public boolean isMissingSparse(int indexOfIndex)
isMissingSparse in interface weka.core.InstanceindexOfIndex - the index of the attribute's index
public weka.core.Instance mergeInstance(weka.core.Instance inst)
mergeInstance in interface weka.core.Instanceinst - the instance to be merged with this one
public int numAttributes()
numAttributes in interface weka.core.Instancepublic int numClasses()
numClasses in interface weka.core.InstanceUnassignedDatasetException - if instance doesn't have access to any
datasetpublic int numValues()
numValues in interface weka.core.Instancepublic weka.core.Instances relationalValue(int attIndex)
relationalValue in interface weka.core.InstanceattIndex - the attribute's index
IllegalArgumentException - if the attribute is not a relation-valued
attribute
UnassignedDatasetException - if the instance doesn't belong to a
dataset.public weka.core.Instances relationalValue(weka.core.Attribute att)
relationalValue in interface weka.core.Instanceatt - the attribute
IllegalArgumentException - if the attribute is not a relation-valued
attribute
UnassignedDatasetException - if the instance doesn't belong to a
dataset.public void replaceMissingValues(double[] array)
replaceMissingValues in interface weka.core.Instancearray - containing the means and modes
IllegalArgumentException - if numbers of attributes are unequalpublic void setClassMissing()
setClassMissing in interface weka.core.InstanceUnassignedClassException - if the class is not set
UnassignedDatasetException - if the instance doesn't have access to a
datasetpublic void setClassValue(double value)
setClassValue in interface weka.core.Instancevalue - the new attribute value (If the corresponding attribute is
nominal (or a string) then this is the new value's index as a
double).
UnassignedClassException - if the class is not set
UnaddignedDatasetException - if the instance doesn't have access to a
datasetpublic void setClassValue(String value)
setClassValue in interface weka.core.Instancevalue - the new class value (If the class is a string attribute and
the value can't be found, the value is added to the attribute).
UnassignedClassException - if the class is not set
UnassignedDatasetException - if the dataset is not set
IllegalArgumentException - if the attribute is not nominal or a
string, or the value couldn't be found for a nominal attributepublic void setDataset(weka.core.Instances instances)
setDataset in interface weka.core.Instanceinstances - the reference to the datasetpublic void setMissing(int attIndex)
setMissing in interface weka.core.InstanceattIndex - the attribute's indexpublic void setMissing(weka.core.Attribute att)
setMissing in interface weka.core.Instanceatt - the attribute
public void setValue(int attIndex,
double value)
setValue in interface weka.core.InstanceattIndex - the attribute's indexvalue - the new attribute value (If the corresponding attribute is
nominal (or a string) then this is the new value's index as a
double).
public void setValue(int attIndex,
String value)
setValue in interface weka.core.InstanceattIndex - the attribute's indexvalue - the new attribute value (If the attribute is a string
attribute and the value can't be found, the value is added to the
attribute).
UnassignedDatasetException - if the dataset is not set
IllegalArgumentException - if the selected attribute is not nominal
or a string, or the supplied value couldn't be found for a
nominal attribute
public void setValue(weka.core.Attribute att,
double value)
setValue in interface weka.core.Instanceatt - the attributevalue - the new attribute value (If the corresponding attribute is
nominal (or a string) then this is the new value's index as a
double).
public void setValue(weka.core.Attribute att,
String value)
setValue in interface weka.core.Instanceatt - the attributevalue - the new attribute value (If the attribute is a string
attribute and the value can't be found, the value is added to the
attribute).
IllegalArgumentException - if the the attribute is not nominal or a
string, or the value couldn't be found for a nominal attribute
public void setValueSparse(int indexOfIndex,
double value)
setValueSparse in interface weka.core.InstanceindexOfIndex - the index of the attribute's indexvalue - the new attribute value (If the corresponding attribute is
nominal (or a string) then this is the new value's index as a
double).public void setWeight(double weight)
setWeight in interface weka.core.Instanceweight - the weightpublic String stringValue(int attIndex)
stringValue in interface weka.core.InstanceattIndex - the attribute's index
IllegalArgumentException - if the attribute is not a nominal, string,
date, or relation-valued attribute.
UnassignedDatasetException - if the instance doesn't belong to a
dataset.public String stringValue(weka.core.Attribute att)
stringValue in interface weka.core.Instanceatt - the attribute
IllegalArgumentException - if the attribute is not a nominal, string,
date, or relation-valued attribute.
UnassignedDatasetException - if the instance doesn't belong to a
dataset.public double[] toDoubleArray()
toDoubleArray in interface weka.core.Instancepublic String toString()
Instance's toString() method.
toString in class Objectpublic String toString(int attIndex)
toString in interface weka.core.InstanceattIndex - the attribute's index
public String toString(weka.core.Attribute att)
toString in interface weka.core.Instanceatt - the attribute
public String toString(int attIndex,
int afterDecimalPoint)
toString in interface weka.core.InstanceattIndex - the attribute's indexafterDecimalPoint - the maximum number of digits permitted after the
decimal point for numeric values
public String toString(weka.core.Attribute att,
int afterDecimalPoint)
toString in interface weka.core.Instanceatt - the attributeafterDecimalPoint - the maximum number of decimal places to print
public String toStringMaxDecimalDigits(int afterDecimalPoint)
toStringMaxDecimalDigits in interface weka.core.InstanceafterDecimalPoint - the maximum number of digits permitted after the
decimal point for a numeric value
public String toStringNoWeight()
toStringNoWeight in interface weka.core.Instancepublic String toStringNoWeight(int afterDecimalPoint)
toStringNoWeight in interface weka.core.InstanceafterDecimalPoint - maximum number of digits after the decimal point
for numeric values
public double value(int attIndex)
value in interface weka.core.InstanceattIndex - the attribute's index
public double value(weka.core.Attribute att)
value in interface weka.core.Instanceatt - the attribute
public double valueSparse(int indexOfIndex)
valueSparse in interface weka.core.InstanceindexOfIndex - the index of the attribute's index
public double weight()
weight in interface weka.core.Instancepublic boolean equals(Object obj)
equals in class Objectpublic void setExcludeClass(boolean value)
value - if true the class value gets excludedpublic boolean getExcludeClass()
public void setExcludeWeight(boolean value)
value - if true the weight value gets excludedpublic boolean getExcludeWeight()
protected void invalidateHashCode()
protected abstract int computeHashCode()
#m_ExcludeClass,
m_ExcludeWeightpublic int hashCode()
Instance, computes it if neccessary.
hashCode in class ObjectcomputeHashCode()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||