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 WEKAInstance
and allow them to be used in data structures that make use of on object's hash, like maps or hashtables.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description 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
Constructors Modifier Constructor Description protected
AbstractHashableInstance(weka.core.Instance data)
Initializes the wrapper.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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.Instance
copy(double[] values)
Copies the instance but fills up its values based on the given array of doubles.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 thisInstance
, 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(int attIndex)
Tests if a specific value is "missing".boolean
isMissing(weka.core.Attribute att)
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(int attIndex)
Returns the relational value of a relational attribute.weka.core.Instances
relationalValue(weka.core.Attribute att)
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(int attIndex)
Sets a specific value to be "missing".void
setMissing(weka.core.Attribute att)
Sets a specific value to be "missing".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
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
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(int attIndex)
Returns the value of a nominal, string, date, or relational attribute for the instance as a string.String
stringValue(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.String
toString()
Returns the value of theInstance
'stoString()
method.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
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
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(int attIndex)
Returns an instance's attribute value in internal format.double
value(weka.core.Attribute att)
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.
-
-
-
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:
copy
in 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:
copy
in 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:
attribute
in 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:
attributeSparse
in 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:
classAttribute
in 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:
classIndex
in 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:
classIsMissing
in 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:
classValue
in 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:
dataset
in 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:
deleteAttributeAt
in 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:
enumerateAttributes
in 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:
equalHeaders
in 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:
equalHeadersMsg
in 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:
hasMissingValue
in 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:
index
in 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:
insertAttributeAt
in 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:
isMissing
in 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:
isMissing
in 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:
isMissingSparse
in 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:
mergeInstance
in 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:
numAttributes
in interfaceweka.core.Instance
- Returns:
- the number of attributes as an integer
-
numClasses
public int numClasses()
Returns the number of class labels.- Specified by:
numClasses
in 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:
numValues
in 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:
relationalValue
in 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:
relationalValue
in 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:
replaceMissingValues
in 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:
setClassMissing
in 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:
setClassValue
in 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:
setClassValue
in 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:
setDataset
in 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:
setMissing
in 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:
setMissing
in 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:
setValue
in 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:
setValue
in 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:
setValue
in 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:
setValue
in 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:
setValueSparse
in 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:
setWeight
in 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:
stringValue
in 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:
stringValue
in 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:
toDoubleArray
in 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:
toString
in 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:
toString
in 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:
toString
in 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:
toString
in 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:
toStringMaxDecimalDigits
in 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:
toStringNoWeight
in 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:
toStringNoWeight
in 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:
value
in 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:
value
in 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:
valueSparse
in 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:
weight
in 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:
hashCode
in classObject
- Returns:
- the hashcode
- See Also:
computeHashCode()
-
-