edu.cmu.minorthird.classify
Class Example

java.lang.Object
  extended by edu.cmu.minorthird.classify.Example
All Implemented Interfaces:
HasSubpopulationId, Instance, Visible, java.io.Serializable
Direct Known Subclasses:
MultiExample, SGMExample

public class Example
extends java.lang.Object
implements Instance, Visible, java.io.Serializable

An instance that is associated with a ClassLabel. Implements the Instance interface by delegating to a wrapped Instance, so subclasses just need to attach the right label construct.

Author:
William Cohen
See Also:
Serialized Form

Field Summary
protected  Instance instance
           
protected  ClassLabel label
           
protected  double weight
           
 
Constructor Summary
Example(Instance instance, ClassLabel label)
           
Example(Instance instance, ClassLabel label, double weight)
           
 
Method Summary
 Instance asInstance()
          Return an unlabeled version of the example (an Instance)
 java.util.Iterator<Feature> binaryFeatureIterator()
          Return an iterator over all binary features
 java.util.Iterator<Feature> featureIterator()
          Return an iterator over all features
 ClassLabel getLabel()
          get the label associated with the underlying object
 java.lang.Object getSource()
          Get the underlying object
 java.lang.String getSubpopulationId()
          Return the subpopulation Id of the instance.
 double getWeight()
          Get the weight of this example.
 double getWeight(Feature f)
          Get the weight assigned to a feature in the instance.
 java.util.Iterator<Feature> numericFeatureIterator()
          Return an iterator over all numeric features
 int numFeatures()
          Return the number of all features
 void setWeight(double newWeight)
          Change the weight of this example.
 Viewer toGUI()
          Create a viewer
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

instance

protected Instance instance

label

protected ClassLabel label

weight

protected double weight
Constructor Detail

Example

public Example(Instance instance,
               ClassLabel label)

Example

public Example(Instance instance,
               ClassLabel label,
               double weight)
Method Detail

getLabel

public ClassLabel getLabel()
get the label associated with the underlying object


getSource

public final java.lang.Object getSource()
Get the underlying object

Specified by:
getSource in interface Instance

getWeight

public final double getWeight(Feature f)
Get the weight assigned to a feature in the instance.

Specified by:
getWeight in interface Instance

binaryFeatureIterator

public final java.util.Iterator<Feature> binaryFeatureIterator()
Return an iterator over all binary features

Specified by:
binaryFeatureIterator in interface Instance

numericFeatureIterator

public final java.util.Iterator<Feature> numericFeatureIterator()
Return an iterator over all numeric features

Specified by:
numericFeatureIterator in interface Instance

featureIterator

public final java.util.Iterator<Feature> featureIterator()
Return an iterator over all features

Specified by:
featureIterator in interface Instance

numFeatures

public final int numFeatures()
Return the number of all features

Specified by:
numFeatures in interface Instance

getWeight

public final double getWeight()
Get the weight of this example.


setWeight

public final void setWeight(double newWeight)
Change the weight of this example.


getSubpopulationId

public final java.lang.String getSubpopulationId()
Return the subpopulation Id of the instance.

Specified by:
getSubpopulationId in interface HasSubpopulationId
Specified by:
getSubpopulationId in interface Instance

asInstance

public final Instance asInstance()
Return an unlabeled version of the example (an Instance)


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toGUI

public Viewer toGUI()
Create a viewer

Specified by:
toGUI in interface Visible