edu.cmu.minorthird.classify
Class DatasetIndex

java.lang.Object
  extended by edu.cmu.minorthird.classify.DatasetIndex
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BasicFeatureIndex

public class DatasetIndex
extends java.lang.Object
implements java.io.Serializable

An inverted index, mapping features to examples which contain the features.

Author:
William Cohen
See Also:
Serialized Form

Constructor Summary
DatasetIndex()
           
DatasetIndex(Dataset data)
          Construct an index of a dataset.
 
Method Summary
 void addExample(Example e)
          Add a single example to the index.
 double averageFeaturesPerExample()
          Average number of non-zero feature values in examples.
protected  java.util.List<Example> classIndex(java.lang.String label)
           
protected  java.util.List<Example> featureIndex(Feature f)
           
 java.util.Iterator<Feature> featureIterator()
          Iterate over all features indexed.
 Example getExample(Feature f, int i)
          Get i-th example containing feature f.
 Example getExample(java.lang.String label, int i)
          Get i-th example with given class label.
 java.util.Iterator<Example> getNeighbors(Instance instance)
          Get all examples with a feature in common with the given instance.
static void main(java.lang.String[] args)
           
 int numberOfFeatures()
          Number of features indexed.
 int size(Feature f)
          Number of examples containing non-zero values for feature f.
 int size(java.lang.String label)
          Number of examples with the given class label.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DatasetIndex

public DatasetIndex()

DatasetIndex

public DatasetIndex(Dataset data)
Construct an index of a dataset.

Method Detail

addExample

public void addExample(Example e)
Add a single example to the index.


featureIterator

public java.util.Iterator<Feature> featureIterator()
Iterate over all features indexed.


size

public int size(Feature f)
Number of examples containing non-zero values for feature f.


size

public int size(java.lang.String label)
Number of examples with the given class label.


getExample

public Example getExample(Feature f,
                          int i)
Get i-th example containing feature f.


getExample

public Example getExample(java.lang.String label,
                          int i)
Get i-th example with given class label.


getNeighbors

public java.util.Iterator<Example> getNeighbors(Instance instance)
Get all examples with a feature in common with the given instance.


numberOfFeatures

public int numberOfFeatures()
Number of features indexed.


averageFeaturesPerExample

public double averageFeaturesPerExample()
Average number of non-zero feature values in examples.


featureIndex

protected java.util.List<Example> featureIndex(Feature f)

classIndex

protected java.util.List<Example> classIndex(java.lang.String label)

toString

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

main

public static void main(java.lang.String[] args)