edu.cmu.minorthird.classify
Class DatasetLoader

java.lang.Object
  extended by edu.cmu.minorthird.classify.DatasetLoader

public class DatasetLoader
extends java.lang.Object

Dataset i/o. For ordinary datasets, format is one example per line, and the format for a line is:

 type subpopid label feature1 feature2 ...
 
where For example: k subpop1 2 f1=4 fOrange=1 fGreen=92 ... k subpop1 1 f1=1 fBlue=10 fGreen=2 ... k subpop2 3 f1=2 fYellow=1 fRed=42 ... or b NUL +1 f1=2 fOrange=1 fGreen=92 ... b NUL -1 f1=1 fBlue=10 fGreen=2 ... or k subpop1 2 f1 fOrange fGreen ... k subpop1 1 f1 fBlue fGreen ... k subpop2 3 f1 fYellow fRed ... For SequenceDatasets, examples from a diffrerent sequence are separated by a single line containing a "*".

Author:
William Cohen

Constructor Summary
DatasetLoader()
           
 
Method Summary
static java.lang.String getSourceAssignedToExample(java.lang.String fileName, int lineNumber)
          The value that will be returned by example.getSource() for the example read in from the designated location.
 java.lang.Object load(java.io.File f)
          Calls loadFile.
static Dataset loadFile(java.io.File file)
          Load a dataset from a file
static void loadLinkFile(java.io.File file, RealRelationalDataset dataset)
          Load a link file
static Dataset loadMulti(java.io.File file, int numDim)
          Load a dataset from a file
static Dataset loadRegression(java.io.File file)
          Save a dataset that can be used for regression
static void loadRelFile(java.io.File file, RealRelationalDataset dataset)
          Load a relational dataset from a file specifying objs
static void loadRelTempFile(java.io.File file, RealRelationalDataset dataset)
          Load a relational template file
static SequenceDataset loadSequence(java.io.File file)
          Load a SequenceDataset from a file
static Dataset loadSVMStyle(java.io.File file)
           
static void main(java.lang.String[] args)
           
static void save(Dataset dataset, java.io.File file)
          Save a dataset to a file.
static void saveRegression(Dataset dataset, java.io.File file)
          Save a dataset that can be used for regression
static void saveSequence(SequenceDataset dataset, java.io.File file)
          Save a SequenceDataset to a file Each Example in a sequence is saved on a seperate line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatasetLoader

public DatasetLoader()
Method Detail

save

public static void save(Dataset dataset,
                        java.io.File file)
                 throws java.io.IOException
Save a dataset to a file. This should save each example in the order provided by the dataset.iterator()

Throws:
java.io.IOException

saveRegression

public static void saveRegression(Dataset dataset,
                                  java.io.File file)
                           throws java.io.IOException
Save a dataset that can be used for regression

Throws:
java.io.IOException

loadRegression

public static Dataset loadRegression(java.io.File file)
                              throws java.io.IOException,
                                     java.lang.NumberFormatException
Save a dataset that can be used for regression

Throws:
java.io.IOException
java.lang.NumberFormatException

loadFile

public static Dataset loadFile(java.io.File file)
                        throws java.io.IOException,
                               java.lang.NumberFormatException
Load a dataset from a file

Throws:
java.io.IOException
java.lang.NumberFormatException

loadRelFile

public static void loadRelFile(java.io.File file,
                               RealRelationalDataset dataset)
                        throws java.io.IOException,
                               java.lang.NumberFormatException
Load a relational dataset from a file specifying objs

Throws:
java.io.IOException
java.lang.NumberFormatException

loadLinkFile

public static void loadLinkFile(java.io.File file,
                                RealRelationalDataset dataset)
                         throws java.io.IOException,
                                java.lang.NumberFormatException
Load a link file

Throws:
java.io.IOException
java.lang.NumberFormatException

loadRelTempFile

public static void loadRelTempFile(java.io.File file,
                                   RealRelationalDataset dataset)
                            throws java.io.IOException,
                                   java.lang.NumberFormatException
Load a relational template file

Throws:
java.io.IOException
java.lang.NumberFormatException

loadMulti

public static Dataset loadMulti(java.io.File file,
                                int numDim)
                         throws java.io.IOException,
                                java.lang.NumberFormatException
Load a dataset from a file

Throws:
java.io.IOException
java.lang.NumberFormatException

saveSequence

public static void saveSequence(SequenceDataset dataset,
                                java.io.File file)
                         throws java.io.IOException
Save a SequenceDataset to a file Each Example in a sequence is saved on a seperate line. An asterix (*) alone on a line seperates the sequences. Example1,0 Example1,1 Example1,2 ... * Example2,0 Example2,1 ... *

Throws:
java.io.IOException

loadSequence

public static SequenceDataset loadSequence(java.io.File file)
                                    throws java.io.IOException,
                                           java.lang.NumberFormatException
Load a SequenceDataset from a file

Throws:
java.io.IOException
java.lang.NumberFormatException
See Also:
for format

getSourceAssignedToExample

public static java.lang.String getSourceAssignedToExample(java.lang.String fileName,
                                                          int lineNumber)
The value that will be returned by example.getSource() for the example read in from the designated location.


loadSVMStyle

public static Dataset loadSVMStyle(java.io.File file)
                            throws java.io.IOException
Throws:
java.io.IOException

load

public java.lang.Object load(java.io.File f)
                      throws java.io.IOException
Calls loadFile. The Dataset is temporarily swallowed. In other words, don't call this method.

Parameters:
f -
Throws:
java.io.IOException

main

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