|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.AbstractInstance
public abstract class AbstractInstance
Abstract class providing common functionality for the original instance implementations.
Constructor Summary | |
---|---|
AbstractInstance()
|
Method Summary | |
---|---|
Attribute |
attribute(int index)
Returns the attribute with the given index. |
Attribute |
attributeSparse(int indexOfIndex)
Returns the attribute with the given index in the sparse representation. |
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 in internal format. |
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). |
java.util.Enumeration |
enumerateAttributes()
Returns an enumeration of all the attributes. |
boolean |
equalHeaders(Instance inst)
Tests if the headers of two instances are equivalent. |
java.lang.String |
equalHeadersMsg(Instance inst)
Checks if the headers of two instances are equivalent. |
java.lang.String |
getRevision()
Returns the revision string. |
boolean |
hasMissingValue()
Tests whether an instance has a missing value. |
void |
insertAttributeAt(int position)
Inserts an attribute at the given position (0 to numAttributes()). |
boolean |
isMissing(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", given an index in the sparse representation. |
int |
numClasses()
Returns the number of class labels. |
Instances |
relationalValue(Attribute att)
Returns the relational value of a relational attribute. |
Instances |
relationalValue(int attIndex)
Returns the relational value of a relational attribute. |
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(java.lang.String value)
Sets the class value of an instance to the given value. |
void |
setDataset(Instances instances)
Sets the reference to the dataset. |
void |
setMissing(Attribute att)
Sets a specific value to be "missing". |
void |
setMissing(int attIndex)
Sets a specific value to be "missing". |
void |
setValue(Attribute att,
double value)
Sets a specific value in the instance to the given value (internal floating-point format). |
void |
setValue(Attribute att,
java.lang.String value)
Sets a value of an nominal or string attribute to the given value. |
void |
setValue(int attIndex,
java.lang.String value)
Sets a value of a nominal or string attribute to the given value. |
void |
setWeight(double weight)
Sets the weight of an instance. |
java.lang.String |
stringValue(Attribute att)
Returns the value of a nominal, string, date, or relational attribute for the instance as a string. |
java.lang.String |
stringValue(int attIndex)
Returns the value of a nominal, string, date, or relational attribute for the instance as a string. |
java.lang.String |
toString()
Returns the description of one instance. |
java.lang.String |
toString(Attribute att)
Returns the description of one value of the instance as a string. |
java.lang.String |
toString(int attIndex)
Returns the description of one value of the instance as a string. |
double |
value(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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface weka.core.Instance |
---|
index, mergeInstance, numAttributes, numValues, replaceMissingValues, setValue, setValueSparse, toDoubleArray, toStringNoWeight, value |
Methods inherited from interface weka.core.Copyable |
---|
copy |
Constructor Detail |
---|
public AbstractInstance()
Method Detail |
---|
public Attribute attribute(int index)
attribute
in interface Instance
index
- the attribute's index
UnassignedDatasetException
- if instance doesn't have access to a
datasetpublic Attribute attributeSparse(int indexOfIndex)
attributeSparse
in interface Instance
indexOfIndex
- the index of the attribute's index
UnassignedDatasetException
- if instance doesn't have access to a
datasetpublic Attribute classAttribute()
classAttribute
in interface Instance
UnassignedDatasetException
- if the class is not set or the
instance doesn't have access to a datasetpublic int classIndex()
classIndex
in interface Instance
UnassignedDatasetException
- if instance doesn't have access to a datasetpublic boolean classIsMissing()
classIsMissing
in interface Instance
UnassignedClassException
- if the class is not set or the instance doesn't
have access to a datasetpublic double classValue()
classValue
in interface Instance
UnassignedClassException
- if the class is not set or the instance doesn't
have access to a datasetpublic Instances dataset()
dataset
in interface Instance
public void deleteAttributeAt(int position)
deleteAttributeAt
in interface Instance
position
- the attribute's position
java.lang.RuntimeException
- if the instance has access to a
datasetpublic java.util.Enumeration enumerateAttributes()
enumerateAttributes
in interface Instance
UnassignedDatasetException
- if the instance doesn't
have access to a datasetpublic boolean equalHeaders(Instance inst)
equalHeaders
in interface Instance
inst
- another instance
UnassignedDatasetException
- if instance doesn't have access to any
datasetpublic java.lang.String equalHeadersMsg(Instance inst)
equalHeadersMsg
in interface Instance
dataset
- another instance
public boolean hasMissingValue()
hasMissingValue
in interface Instance
UnassignedDatasetException
- if instance doesn't have access to any
datasetpublic void insertAttributeAt(int position)
insertAttributeAt
in interface Instance
position
- the attribute's position
java.lang.RuntimeException
- if the instance has accesss to a
dataset
java.lang.IllegalArgumentException
- if the position is out of rangepublic boolean isMissing(int attIndex)
isMissing
in interface Instance
attIndex
- the attribute's index
public boolean isMissingSparse(int indexOfIndex)
isMissingSparse
in interface Instance
indexOfIndex
- the index of the attribute's index
public boolean isMissing(Attribute att)
isMissing
in interface Instance
att
- the attribute
public int numClasses()
numClasses
in interface Instance
UnassignedDatasetException
- if instance doesn't have access to any
datasetpublic void setClassMissing()
setClassMissing
in interface Instance
UnassignedClassException
- if the class is not set
UnassignedDatasetException
- if the instance doesn't
have access to a datasetpublic void setClassValue(double value)
setClassValue
in interface Instance
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).
UnassignedClassException
- if the class is not set
UnaddignedDatasetException
- if the instance doesn't
have access to a datasetpublic final void setClassValue(java.lang.String value)
setClassValue
in interface Instance
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).
UnassignedClassException
- if the class is not set
UnassignedDatasetException
- if the dataset is not set
java.lang.IllegalArgumentException
- if the attribute is not
nominal or a string, or the value couldn't be found for a nominal
attributepublic final void setDataset(Instances instances)
setDataset
in interface Instance
instances
- the reference to the datasetpublic final void setMissing(int attIndex)
setMissing
in interface Instance
attIndex
- the attribute's indexpublic final void setMissing(Attribute att)
setMissing
in interface Instance
att
- the attributepublic final void setValue(int attIndex, java.lang.String value)
setValue
in interface Instance
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).
UnassignedDatasetException
- if the dataset is not set
java.lang.IllegalArgumentException
- if the selected
attribute is not nominal or a string, or the supplied value couldn't
be found for a nominal attributepublic final void setValue(Attribute att, double value)
setValue
in interface Instance
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).public final void setValue(Attribute att, java.lang.String value)
setValue
in interface Instance
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).
java.lang.IllegalArgumentException
- if the the attribute is not
nominal or a string, or the value couldn't be found for a nominal
attributepublic final void setWeight(double weight)
setWeight
in interface Instance
weight
- the weightpublic final Instances relationalValue(int attIndex)
relationalValue
in interface Instance
attIndex
- the attribute's index
java.lang.IllegalArgumentException
- if the attribute is not a
relation-valued attribute
UnassignedDatasetException
- if the instance doesn't belong
to a dataset.public final Instances relationalValue(Attribute att)
relationalValue
in interface Instance
att
- the attribute
java.lang.IllegalArgumentException
- if the attribute is not a
relation-valued attribute
UnassignedDatasetException
- if the instance doesn't belong
to a dataset.public final java.lang.String stringValue(int attIndex)
stringValue
in interface Instance
attIndex
- the attribute's index
java.lang.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 final java.lang.String stringValue(Attribute att)
stringValue
in interface Instance
att
- the attribute
java.lang.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 java.lang.String toString()
toString
in class java.lang.Object
public final java.lang.String toString(int attIndex)
toString
in interface Instance
attIndex
- the attribute's index
public final java.lang.String toString(Attribute att)
toString
in interface Instance
att
- the attribute
public double value(Attribute att)
value
in interface Instance
att
- the attribute
public double valueSparse(int indexOfIndex)
valueSparse
in interface Instance
indexOfIndex
- the index of the attribute's index
public final double weight()
weight
in interface Instance
public java.lang.String getRevision()
getRevision
in interface RevisionHandler
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |