Package weka.core
Class AbstractHashableInstance
- java.lang.Object
-
- weka.core.AbstractHashableInstance
-
- All Implemented Interfaces:
Serializable,weka.core.Copyable,weka.core.Instance
- Direct Known Subclasses:
HashableInstanceUsingString,HashableInstanceUsingSum
public abstract class AbstractHashableInstance extends Object implements Serializable, weka.core.Instance
Ancestor for instance classes that wraps around any WEKAInstanceand allow them to be used in data structures that make use of on object's hash, like maps or hashtables.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.core.Instancem_Datathe wrapped instance.protected booleanm_ExcludeClasswhether to exclude the class from the hashcode.protected booleanm_ExcludeWeightwhether to exclude the weight from the hashcode.protected Integerm_HashCodethe current hashcode.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractHashableInstance(weka.core.Instance data)Initializes the wrapper.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidassign(AbstractHashableInstance inst)Assigns all the data, apart from wrapped instance, that the provided hashable instance provides.weka.core.Attributeattribute(int index)Returns the attribute with the given index.weka.core.AttributeattributeSparse(int indexOfIndex)Returns the attribute with the given index in the sparse representation.weka.core.AttributeclassAttribute()Returns class attribute.intclassIndex()Returns the class attribute's index.booleanclassIsMissing()Tests if an instance's class is missing.doubleclassValue()Returns an instance's class value as a floating-point number.protected abstract intcomputeHashCode()Computes the hashcode.Objectcopy()This method produces a shallow copy of an object.weka.core.Instancecopy(double[] values)Copies the instance but fills up its values based on the given array of doubles.weka.core.Instancesdataset()Returns the dataset this instance has access to.voiddeleteAttributeAt(int position)Deletes an attribute at the given position (0 to numAttributes() - 1).EnumerationenumerateAttributes()Returns an enumeration of all the attributes.booleanequalHeaders(weka.core.Instance inst)Tests if the headers of two instances are equivalent.StringequalHeadersMsg(weka.core.Instance inst)Checks if the headers of two instances are equivalent.booleanequals(Object obj)Returns only true if the same class and the same hashcode.booleangetExcludeClass()Returns whether the class is excluded from the hashcode computation.booleangetExcludeWeight()Returns whether the weight is excluded from the hashcode computation.inthashCode()Returns the hashcode of thisInstance, computes it if neccessary.booleanhasMissingValue()Tests whether an instance has a missing value.intindex(int position)Returns the index of the attribute stored at the given position in the sparse representation.voidinsertAttributeAt(int position)Inserts an attribute at the given position (0 to numAttributes()).protected voidinvalidateHashCode()Invalidates the hash code.booleanisMissing(int attIndex)Tests if a specific value is "missing".booleanisMissing(weka.core.Attribute att)Tests if a specific value is "missing".booleanisMissingSparse(int indexOfIndex)Tests if a specific value is "missing" in the sparse representation.weka.core.InstancemergeInstance(weka.core.Instance inst)Merges this instance with the given instance and returns the result.intnumAttributes()Returns the number of attributes.intnumClasses()Returns the number of class labels.intnumValues()Returns the number of values present in a sparse representation.weka.core.InstancesrelationalValue(int attIndex)Returns the relational value of a relational attribute.weka.core.InstancesrelationalValue(weka.core.Attribute att)Returns the relational value of a relational attribute.voidreplaceMissingValues(double[] array)Replaces all missing values in the instance with the values contained in the given array.voidsetClassMissing()Sets the class value of an instance to be "missing".voidsetClassValue(double value)Sets the class value of an instance to the given value (internal floating-point format).voidsetClassValue(String value)Sets the class value of an instance to the given value.voidsetDataset(weka.core.Instances instances)Sets the reference to the dataset.voidsetExcludeClass(boolean value)Sets whether to exclude the class from the hashcode computation.voidsetExcludeWeight(boolean value)Sets whether to exclude the weight from the hashcode computation.voidsetMissing(int attIndex)Sets a specific value to be "missing".voidsetMissing(weka.core.Attribute att)Sets a specific value to be "missing".voidsetValue(int attIndex, double value)Sets a specific value in the instance to the given value (internal floating-point format).voidsetValue(int attIndex, String value)Sets a value of a nominal or string attribute to the given value.voidsetValue(weka.core.Attribute att, double value)Sets a specific value in the instance to the given value (internal floating-point format).voidsetValue(weka.core.Attribute att, String value)Sets a value of an nominal or string attribute to the given value.voidsetValueSparse(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.voidsetWeight(double weight)Sets the weight of an instance.StringstringValue(int attIndex)Returns the value of a nominal, string, date, or relational attribute for the instance as a string.StringstringValue(weka.core.Attribute att)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.StringtoString()Returns the value of theInstance'stoString()method.StringtoString(int attIndex)Returns the description of one value of the instance as a string.StringtoString(int attIndex, int afterDecimalPoint)Returns the description of one value of the instance as a string.StringtoString(weka.core.Attribute att)Returns the description of one value of the instance as a string.StringtoString(weka.core.Attribute att, int afterDecimalPoint)Returns the description of one value of the instance as a string.StringtoStringMaxDecimalDigits(int afterDecimalPoint)Returns the description of one instance with any numeric values printed at the supplied maximum number of decimal places.StringtoStringNoWeight()Returns the description of one instance (without weight appended).StringtoStringNoWeight(int afterDecimalPoint)Returns the description of one instance (without weight appended).doublevalue(int attIndex)Returns an instance's attribute value in internal format.doublevalue(weka.core.Attribute att)Returns an instance's attribute value in internal format.doublevalueSparse(int indexOfIndex)Returns an instance's attribute value in internal format, given an index in the sparse representation.doubleweight()Returns the instance's weight.
-
-
-
Field Detail
-
m_HashCode
protected Integer m_HashCode
the current hashcode.
-
m_Data
protected weka.core.Instance m_Data
the wrapped instance.
-
m_ExcludeClass
protected boolean m_ExcludeClass
whether to exclude the class from the hashcode.
-
m_ExcludeWeight
protected boolean m_ExcludeWeight
whether to exclude the weight from the hashcode.
-
-
Method Detail
-
copy
public Object copy()
This method produces a shallow copy of an object. It does the same as the clone() method in Object, which also produces a shallow copy.- Specified by:
copyin interfaceweka.core.Copyable- Returns:
- the copy
-
copy
public weka.core.Instance copy(double[] values)
Copies the instance but fills up its values based on the given array of doubles. The copy has access to the same dataset.- Specified by:
copyin interfaceweka.core.Instance- Parameters:
values- the array with new values- Returns:
- the new instance
-
assign
protected void assign(AbstractHashableInstance inst)
Assigns all the data, apart from wrapped instance, that the provided hashable instance provides.- Parameters:
inst- the hashable instance to get the data from
-
attribute
public weka.core.Attribute attribute(int index)
Returns the attribute with the given index.- Specified by:
attributein interfaceweka.core.Instance- Parameters:
index- the attribute's index- Returns:
- the attribute at the given position
- Throws:
weka.core.UnassignedDatasetException- if instance doesn't have access to a dataset
-
attributeSparse
public weka.core.Attribute attributeSparse(int indexOfIndex)
Returns the attribute with the given index in the sparse representation. Same as attribute(int) for a DenseInstance.- Specified by:
attributeSparsein interfaceweka.core.Instance- Parameters:
indexOfIndex- the index of the attribute's index- Returns:
- the attribute at the given position
- Throws:
weka.core.UnassignedDatasetException- if instance doesn't have access to a dataset
-
classAttribute
public weka.core.Attribute classAttribute()
Returns class attribute.- Specified by:
classAttributein interfaceweka.core.Instance- Returns:
- the class attribute
- Throws:
weka.core.UnassignedDatasetException- if the class is not set or the instance doesn't have access to a dataset
-
classIndex
public int classIndex()
Returns the class attribute's index.- Specified by:
classIndexin interfaceweka.core.Instance- Returns:
- the class index as an integer
- Throws:
weka.core.UnassignedDatasetException- if instance doesn't have access to a dataset
-
classIsMissing
public boolean classIsMissing()
Tests if an instance's class is missing.- Specified by:
classIsMissingin interfaceweka.core.Instance- Returns:
- true if the instance's class is missing
- Throws:
weka.core.UnassignedClassException- if the class is not set or the instance doesn't have access to a dataset
-
classValue
public double classValue()
Returns an instance's class value as a floating-point number.- Specified by:
classValuein interfaceweka.core.Instance- Returns:
- the corresponding value as a double (If the corresponding attribute is nominal (or a string) then it returns the value's index as a double).
- Throws:
weka.core.UnassignedClassException- if the class is not set or the instance doesn't have access to a dataset
-
dataset
public weka.core.Instances dataset()
Returns the dataset this instance has access to. (ie. obtains information about attribute types from) Null if the instance doesn't have access to a dataset.- Specified by:
datasetin interfaceweka.core.Instance- Returns:
- the dataset the instance has accesss to
-
deleteAttributeAt
public void deleteAttributeAt(int position)
Deletes an attribute at the given position (0 to numAttributes() - 1). Only succeeds if the instance does not have access to any dataset because otherwise inconsistencies could be introduced.- Specified by:
deleteAttributeAtin interfaceweka.core.Instance- Parameters:
position- the attribute's position- Throws:
RuntimeException- if the instance has access to a dataset
-
enumerateAttributes
public Enumeration enumerateAttributes()
Returns an enumeration of all the attributes.- Specified by:
enumerateAttributesin interfaceweka.core.Instance- Returns:
- enumeration of all the attributes
- Throws:
weka.core.UnassignedDatasetException- if the instance doesn't have access to a dataset
-
equalHeaders
public boolean equalHeaders(weka.core.Instance inst)
Tests if the headers of two instances are equivalent.- Specified by:
equalHeadersin interfaceweka.core.Instance- Parameters:
inst- another instance- Returns:
- true if the header of the given instance is equivalent to this instance's header
- Throws:
weka.core.UnassignedDatasetException- if instance doesn't have access to any dataset
-
equalHeadersMsg
public String equalHeadersMsg(weka.core.Instance inst)
Checks if the headers of two instances are equivalent. If not, then returns a message why they differ.- Specified by:
equalHeadersMsgin interfaceweka.core.Instance- Parameters:
dataset- another instance- Returns:
- null if the header of the given instance is equivalent to this instance's header, otherwise a message with details on why they differ
-
hasMissingValue
public boolean hasMissingValue()
Tests whether an instance has a missing value. Skips the class attribute if set.- Specified by:
hasMissingValuein interfaceweka.core.Instance- Returns:
- true if instance has a missing value.
- Throws:
weka.core.UnassignedDatasetException- if instance doesn't have access to any dataset
-
index
public int index(int position)
Returns the index of the attribute stored at the given position in the sparse representation. Identify function for an instance of type DenseInstance.- Specified by:
indexin interfaceweka.core.Instance- Parameters:
position- the position- Returns:
- the index of the attribute stored at the given position
-
insertAttributeAt
public void insertAttributeAt(int position)
Inserts an attribute at the given position (0 to numAttributes()). Only succeeds if the instance does not have access to any dataset because otherwise inconsistencies could be introduced.- Specified by:
insertAttributeAtin interfaceweka.core.Instance- Parameters:
position- the attribute's position- Throws:
RuntimeException- if the instance has accesss to a datasetIllegalArgumentException- if the position is out of range
-
isMissing
public boolean isMissing(int attIndex)
Tests if a specific value is "missing".- Specified by:
isMissingin interfaceweka.core.Instance- Parameters:
attIndex- the attribute's index- Returns:
- true if the value is "missing"
-
isMissing
public boolean isMissing(weka.core.Attribute att)
Tests if a specific value is "missing". The given attribute has to belong to a dataset.- Specified by:
isMissingin interfaceweka.core.Instance- Parameters:
att- the attribute- Returns:
- true if the value is "missing"
-
isMissingSparse
public boolean isMissingSparse(int indexOfIndex)
Tests if a specific value is "missing" in the sparse representation. Samse as isMissing(int) for a DenseInstance.- Specified by:
isMissingSparsein interfaceweka.core.Instance- Parameters:
indexOfIndex- the index of the attribute's index- Returns:
- true if the value is "missing"
-
mergeInstance
public weka.core.Instance mergeInstance(weka.core.Instance inst)
Merges this instance with the given instance and returns the result. Dataset is set to null. The returned instance is of the same type as this instance.- Specified by:
mergeInstancein interfaceweka.core.Instance- Parameters:
inst- the instance to be merged with this one- Returns:
- the merged instances
-
numAttributes
public int numAttributes()
Returns the number of attributes.- Specified by:
numAttributesin interfaceweka.core.Instance- Returns:
- the number of attributes as an integer
-
numClasses
public int numClasses()
Returns the number of class labels.- Specified by:
numClassesin interfaceweka.core.Instance- Returns:
- the number of class labels as an integer if the class attribute is nominal, 1 otherwise.
- Throws:
weka.core.UnassignedDatasetException- if instance doesn't have access to any dataset
-
numValues
public int numValues()
Returns the number of values present in a sparse representation.- Specified by:
numValuesin interfaceweka.core.Instance- Returns:
- the number of values
-
relationalValue
public weka.core.Instances relationalValue(int attIndex)
Returns the relational value of a relational attribute.- Specified by:
relationalValuein interfaceweka.core.Instance- Parameters:
attIndex- the attribute's index- Returns:
- the corresponding relation as an Instances object
- Throws:
IllegalArgumentException- if the attribute is not a relation-valued attributeweka.core.UnassignedDatasetException- if the instance doesn't belong to a dataset.
-
relationalValue
public weka.core.Instances relationalValue(weka.core.Attribute att)
Returns the relational value of a relational attribute.- Specified by:
relationalValuein interfaceweka.core.Instance- Parameters:
att- the attribute- Returns:
- the corresponding relation as an Instances object
- Throws:
IllegalArgumentException- if the attribute is not a relation-valued attributeweka.core.UnassignedDatasetException- if the instance doesn't belong to a dataset.
-
replaceMissingValues
public void replaceMissingValues(double[] array)
Replaces all missing values in the instance with the values contained in the given array. A deep copy of the vector of attribute values is performed before the values are replaced.- Specified by:
replaceMissingValuesin interfaceweka.core.Instance- Parameters:
array- containing the means and modes- Throws:
IllegalArgumentException- if numbers of attributes are unequal
-
setClassMissing
public void setClassMissing()
Sets the class value of an instance to be "missing". A deep copy of the vector of attribute values is performed before the value is set to be missing.- Specified by:
setClassMissingin interfaceweka.core.Instance- Throws:
weka.core.UnassignedClassException- if the class is not setweka.core.UnassignedDatasetException- if the instance doesn't have access to a dataset
-
setClassValue
public void setClassValue(double value)
Sets the class value of an instance to the given value (internal floating-point format). A deep copy of the vector of attribute values is performed before the value is set.- Specified by:
setClassValuein interfaceweka.core.Instance- Parameters:
value- the new attribute value (If the corresponding attribute is nominal (or a string) then this is the new value's index as a double).- Throws:
weka.core.UnassignedClassException- if the class is not setUnaddignedDatasetException- if the instance doesn't have access to a dataset
-
setClassValue
public void setClassValue(String value)
Sets the class value of an instance to the given value. A deep copy of the vector of attribute values is performed before the value is set.- Specified by:
setClassValuein interfaceweka.core.Instance- Parameters:
value- 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).- Throws:
weka.core.UnassignedClassException- if the class is not setweka.core.UnassignedDatasetException- if the dataset is not setIllegalArgumentException- if the attribute is not nominal or a string, or the value couldn't be found for a nominal attribute
-
setDataset
public void setDataset(weka.core.Instances instances)
Sets the reference to the dataset. Does not check if the instance is compatible with the dataset. Note: the dataset does not know about this instance. If the structure of the dataset's header gets changed, this instance will not be adjusted automatically.- Specified by:
setDatasetin interfaceweka.core.Instance- Parameters:
instances- the reference to the dataset
-
setMissing
public void setMissing(int attIndex)
Sets a specific value to be "missing". Performs a deep copy of the vector of attribute values before the value is set to be missing.- Specified by:
setMissingin interfaceweka.core.Instance- Parameters:
attIndex- the attribute's index
-
setMissing
public void setMissing(weka.core.Attribute att)
Sets a specific value to be "missing". Performs a deep copy of the vector of attribute values before the value is set to be missing. The given attribute has to belong to a dataset.- Specified by:
setMissingin interfaceweka.core.Instance- Parameters:
att- the attribute
-
setValue
public void setValue(int attIndex, double value)Sets a specific value in the instance to the given value (internal floating-point format). Performs a deep copy of the vector of attribute values before the value is set.- Specified by:
setValuein interfaceweka.core.Instance- Parameters:
attIndex- 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).
-
setValue
public void setValue(int attIndex, String value)Sets a value of a nominal or string attribute to the given value. Performs a deep copy of the vector of attribute values before the value is set.- Specified by:
setValuein interfaceweka.core.Instance- Parameters:
attIndex- 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).- Throws:
weka.core.UnassignedDatasetException- if the dataset is not setIllegalArgumentException- if the selected attribute is not nominal or a string, or the supplied value couldn't be found for a nominal attribute
-
setValue
public void setValue(weka.core.Attribute att, double value)Sets a specific value in the instance to the given value (internal floating-point format). Performs a deep copy of the vector of attribute values before the value is set, so if you are planning on calling setValue many times it may be faster to create a new instance using toDoubleArray. The given attribute has to belong to a dataset.- Specified by:
setValuein interfaceweka.core.Instance- Parameters:
att- 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).
-
setValue
public void setValue(weka.core.Attribute att, String value)Sets a value of an nominal or string attribute to the given value. Performs a deep copy of the vector of attribute values before the value is set, so if you are planning on calling setValue many times it may be faster to create a new instance using toDoubleArray. The given attribute has to belong to a dataset.- Specified by:
setValuein interfaceweka.core.Instance- Parameters:
att- 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).- Throws:
IllegalArgumentException- if the attribute is not nominal or a string, or the value couldn't be found for a nominal attribute
-
setValueSparse
public 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. Performs a deep copy of the vector of attribute values before the value is set. Same as setValue(int, double) for a DenseInstance.- Specified by:
setValueSparsein interfaceweka.core.Instance- Parameters:
indexOfIndex- 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).
-
setWeight
public void setWeight(double weight)
Sets the weight of an instance.- Specified by:
setWeightin interfaceweka.core.Instance- Parameters:
weight- the weight
-
stringValue
public String stringValue(int attIndex)
Returns the value of a nominal, string, date, or relational attribute for the instance as a string.- Specified by:
stringValuein interfaceweka.core.Instance- Parameters:
attIndex- the attribute's index- Returns:
- the value as a string
- Throws:
IllegalArgumentException- if the attribute is not a nominal, string, date, or relation-valued attribute.weka.core.UnassignedDatasetException- if the instance doesn't belong to a dataset.
-
stringValue
public String stringValue(weka.core.Attribute att)
Returns the value of a nominal, string, date, or relational attribute for the instance as a string.- Specified by:
stringValuein interfaceweka.core.Instance- Parameters:
att- the attribute- Returns:
- the value as a string
- Throws:
IllegalArgumentException- if the attribute is not a nominal, string, date, or relation-valued attribute.weka.core.UnassignedDatasetException- if the instance doesn't belong to a dataset.
-
toDoubleArray
public double[] toDoubleArray()
Returns the values of each attribute as an array of doubles.- Specified by:
toDoubleArrayin interfaceweka.core.Instance- Returns:
- an array containing all the instance attribute values
-
toString
public String toString()
Returns the value of theInstance'stoString()method.
-
toString
public String toString(int attIndex)
Returns the description of one value of the instance as a string. If the instance doesn't have access to a dataset, it returns the internal floating-point value. Quotes string values that contain whitespace characters, or if they are a question mark.- Specified by:
toStringin interfaceweka.core.Instance- Parameters:
attIndex- the attribute's index- Returns:
- the value's description as a string
-
toString
public String toString(weka.core.Attribute att)
Returns the description of one value of the instance as a string. If the instance doesn't have access to a dataset it returns the internal floating-point value. Quotes string values that contain whitespace characters, or if they are a question mark. The given attribute has to belong to a dataset.- Specified by:
toStringin interfaceweka.core.Instance- Parameters:
att- the attribute- Returns:
- the value's description as a string
-
toString
public String toString(int attIndex, int afterDecimalPoint)
Returns the description of one value of the instance as a string. If the instance doesn't have access to a dataset, it returns the internal floating-point value. Quotes string values that contain whitespace characters, or if they are a question mark.- Specified by:
toStringin interfaceweka.core.Instance- Parameters:
attIndex- the attribute's indexafterDecimalPoint- the maximum number of digits permitted after the decimal point for numeric values- Returns:
- the value's description as a string
-
toString
public String toString(weka.core.Attribute att, int afterDecimalPoint)
Returns the description of one value of the instance as a string. If the instance doesn't have access to a dataset it returns the internal floating-point value. Quotes string values that contain whitespace characters, or if they are a question mark. The given attribute has to belong to a dataset.- Specified by:
toStringin interfaceweka.core.Instance- Parameters:
att- the attributeafterDecimalPoint- the maximum number of decimal places to print- Returns:
- the value's description as a string
-
toStringMaxDecimalDigits
public String toStringMaxDecimalDigits(int afterDecimalPoint)
Returns the description of one instance with any numeric values printed at the supplied maximum number of decimal places. If the instance doesn't have access to a dataset, it returns the internal floating-point values. Quotes string values that contain whitespace characters.- Specified by:
toStringMaxDecimalDigitsin interfaceweka.core.Instance- Parameters:
afterDecimalPoint- the maximum number of digits permitted after the decimal point for a numeric value- Returns:
- the instance's description as a string
-
toStringNoWeight
public String toStringNoWeight()
Returns the description of one instance (without weight appended). If the instance doesn't have access to a dataset, it returns the internal floating-point values. Quotes string values that contain whitespace characters. This method is used by getRandomNumberGenerator() in Instances.java in order to maintain backwards compatibility with weka 3.4.- Specified by:
toStringNoWeightin interfaceweka.core.Instance- Returns:
- the instance's description as a string
-
toStringNoWeight
public String toStringNoWeight(int afterDecimalPoint)
Returns the description of one instance (without weight appended). If the instance doesn't have access to a dataset, it returns the internal floating-point values. Quotes string values that contain whitespace characters. This method is used by getRandomNumberGenerator() in Instances.java in order to maintain backwards compatibility with weka 3.4.- Specified by:
toStringNoWeightin interfaceweka.core.Instance- Parameters:
afterDecimalPoint- maximum number of digits after the decimal point for numeric values- Returns:
- the instance's description as a string
-
value
public double value(int attIndex)
Returns an instance's attribute value in internal format.- Specified by:
valuein interfaceweka.core.Instance- Parameters:
attIndex- the attribute's index- Returns:
- the specified value as a double (If the corresponding attribute is nominal (or a string) then it returns the value's index as a double).
-
value
public double value(weka.core.Attribute att)
Returns an instance's attribute value in internal format. The given attribute has to belong to a dataset.- Specified by:
valuein interfaceweka.core.Instance- Parameters:
att- the attribute- Returns:
- the specified value as a double (If the corresponding attribute is nominal (or a string) then it returns the value's index as a double).
-
valueSparse
public double valueSparse(int indexOfIndex)
Returns an instance's attribute value in internal format, given an index in the sparse representation. Same as value(int) for a DenseInstance.- Specified by:
valueSparsein interfaceweka.core.Instance- Parameters:
indexOfIndex- the index of the attribute's index- Returns:
- the specified value as a double (If the corresponding attribute is nominal (or a string) then it returns the value's index as a double).
-
weight
public double weight()
Returns the instance's weight.- Specified by:
weightin interfaceweka.core.Instance- Returns:
- the instance's weight as a double
-
equals
public boolean equals(Object obj)
Returns only true if the same class and the same hashcode.
-
setExcludeClass
public void setExcludeClass(boolean value)
Sets whether to exclude the class from the hashcode computation.- Parameters:
value- if true the class value gets excluded
-
getExcludeClass
public boolean getExcludeClass()
Returns whether the class is excluded from the hashcode computation.- Returns:
- true if the class is excluded
-
setExcludeWeight
public void setExcludeWeight(boolean value)
Sets whether to exclude the weight from the hashcode computation.- Parameters:
value- if true the weight value gets excluded
-
getExcludeWeight
public boolean getExcludeWeight()
Returns whether the weight is excluded from the hashcode computation.- Returns:
- true if the weight is excluded
-
invalidateHashCode
protected void invalidateHashCode()
Invalidates the hash code.
-
computeHashCode
protected abstract int computeHashCode()
Computes the hashcode.- Returns:
- the hash code
- See Also:
m_ExcludeWeight
-
hashCode
public int hashCode()
Returns the hashcode of thisInstance, computes it if neccessary.- Overrides:
hashCodein classObject- Returns:
- the hashcode
- See Also:
computeHashCode()
-
-