|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umass.cs.mallet.base.types.Instance
A machine learning "example" to be used in training, testing or performance of various machine learning algorithms.
An instance contains four generic fields of predefined name: "data", "target", "name", and "source". "Data" holds the data represented `by the instance, "target" is often a label associated with the instance, "name" is a short identifying name for the instance (such as a filename), and "source" is human-readable sourceinformation, (such as the original text).
Each field has no predefined type, and may change type as the instance
is processed. For example, the data field may start off being a string that
represents a file name and then be processed by a Pipe
into a CharSequence
representing the contents of the file, and eventually to a feature vector
holding indices into an Alphabet
holding words found in the file.
It is up to each pipe which fields in the Instance it modifies; the most common
case is that the pipe modifies the data field.
Generally speaking, there are two modes of operation for Instances. (1) An instance gets created and passed through a Pipe, and the resulting data/target/name/source fields are used. This is generally done for training instances. (2) An instance gets created with raw values in its slots, then different users of the instance call newPipedCopy() with their respective different pipes. This might be done for test instances at "performance" time.
Instances can be made immutable if locked. Although unlocked Instances are mutable, typically the only code that changes the values in the four slots is inside Pipes.
Note that constructing an instance with a pipe argument means
"Construct the instance and then run it through the pipe".
InstanceList
uses this method
when adding instances through a pipeInputIterator.
Pipe
,
Alphabet
,
InstanceList
,
Serialized FormNested Class Summary | |
static interface |
Instance.Iterator
|
Constructor Summary | |
Instance(java.lang.Object data,
java.lang.Object target,
java.lang.Object name,
java.lang.Object source)
|
|
Instance(java.lang.Object data,
java.lang.Object target,
java.lang.Object name,
java.lang.Object source,
Pipe p)
Initialize the slots with the given four values, then put the Instance through the given pipe, then lock the instance. |
Method Summary | |
void |
clearSource()
|
java.lang.Object |
getData()
|
java.lang.Object |
getData(Pipe p)
This is a left-over convenience method that may be removed. |
Labeling |
getLabeling()
|
java.lang.Object |
getName()
|
double |
getNumericProperty(java.lang.String key)
|
Pipe |
getPipe()
|
Instance |
getPipedCopy(Pipe p)
|
PropertyList |
getProperties()
|
java.lang.Object |
getProperty(java.lang.String key)
|
PropertyList |
getPropertyList()
|
java.lang.Object |
getSource()
|
java.lang.Object |
getTarget()
|
boolean |
hasProperty(java.lang.String key)
|
boolean |
isLocked()
|
void |
setData(java.lang.Object d)
|
void |
setLabeling(Labeling l)
|
void |
setLock()
|
void |
setName(java.lang.Object n)
|
void |
setNumericProperty(java.lang.String key,
double value)
|
protected void |
setPipe(Pipe p)
|
void |
setProperty(java.lang.String key,
java.lang.Object value)
|
void |
setPropertyList(PropertyList p)
|
void |
setSource(java.lang.Object s)
|
void |
setTarget(java.lang.Object t)
|
Instance |
shallowCopy()
|
void |
unLock()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Instance(java.lang.Object data, java.lang.Object target, java.lang.Object name, java.lang.Object source)
public Instance(java.lang.Object data, java.lang.Object target, java.lang.Object name, java.lang.Object source, Pipe p)
Method Detail |
public java.lang.Object getData()
public java.lang.Object getTarget()
public java.lang.Object getName()
public java.lang.Object getSource()
public Pipe getPipe()
public PropertyList getPropertyList()
public java.lang.Object getData(Pipe p)
public boolean isLocked()
public void setLock()
public void unLock()
public Instance getPipedCopy(Pipe p)
public Labeling getLabeling()
protected void setPipe(Pipe p)
public void setData(java.lang.Object d)
public void setTarget(java.lang.Object t)
public void setLabeling(Labeling l)
public void setName(java.lang.Object n)
public void setSource(java.lang.Object s)
public void clearSource()
public void setPropertyList(PropertyList p)
public Instance shallowCopy()
public void setProperty(java.lang.String key, java.lang.Object value)
public void setNumericProperty(java.lang.String key, double value)
public PropertyList getProperties()
public java.lang.Object getProperty(java.lang.String key)
public double getNumericProperty(java.lang.String key)
public boolean hasProperty(java.lang.String key)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |