at.tuwien.ifs.somtoolbox.data
Class InputDataWriter

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.data.InputDataWriter

public class InputDataWriter
extends Object

This class gathers methods to write certain InputData, TemplateVector and SOMLibClassInformation in a certain number of file formats, such as SOMLib, WEKA ARFF, SOMPak and ESOM.

Version:
$Id: InputDataWriter.java 3733 2010-07-31 16:32:07Z mayer $
Author:
Rudolf Mayer

Constructor Summary
InputDataWriter()
           
 
Method Summary
static String getWekaClassHeader(String[] classNames)
           
static void writeAsESOM(InputData data, String fileName)
          Writes the data to ESOM lrn/cls format.
static void writeAsESOM(SOMLibClassInformation classInfo, String fileName)
          Writes the class information as ESOM cls file.
static void writeAsOrange(InputData data, String fileName)
          Writes input data in the tab-separated format used by the Orange data mining toolkit (see http://www.ailab.si/orange/)
static void writeAsSOMLib(HashMap<String,String> classInfo, HashSet<String> classNames, String fileName)
          Writes the class information to a file in SOMLib format.
static void writeAsSOMLib(InputData data, String fileName)
           
static void writeAsSOMLib(InputData data, TemplateVector templateVector, SOMLibClassInformation classInformation, boolean tabSeparatedClassFile, String basicFileName)
          Writes the class information to a file.
static void writeAsSOMLib(InputData data, TemplateVector templateVector, SOMLibClassInformation classInformation, String basicFileName)
          Writes the class information to a file.
static void writeAsSOMLib(SOMLibClassInformation classInfo, String fileName)
          Writes the class information to a file in SOMLib format.
static void writeAsSOMLib(TemplateVector tv, String fileName)
           
static void writeAsSOMPAK(InputData data, String fileName)
          Writes input data in the SOMPAK format (see http://www.cis.hut.fi/projects/somtoolbox/package/docs2/som_read_data.html)
static void writeAsWekaARFF(InputData data, String fileName, boolean writeInstanceNames, boolean skipInputsWithoutClass)
          Writes the data to Weka ARFF format.
static void writeElementToFile(PrintWriter writer, int i, TemplateVectorElement e)
           
static void writeHeaderToFile(PrintWriter writer, int numVectors, int dim)
           
static void writeInputDatumToFile(PrintWriter writer, InputDatum inputDatum)
           
static void writeInputDatumToFile(PrintWriter writer, String label, cern.colt.matrix.DoubleMatrix1D vector)
           
static void writeTempplateHeaderToFile(PrintWriter writer, String fileName, int numVectors, int dim, int numInfo)
           
static void writeToFileTabSeparated(SOMLibClassInformation classInfo, String fileName)
          Writes the class information to a tab-separated file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputDataWriter

public InputDataWriter()
Method Detail

writeAsESOM

public static void writeAsESOM(InputData data,
                               String fileName)
                        throws IOException,
                               SOMLibFileFormatException
Writes the data to ESOM lrn/cls format.

Throws:
IOException
SOMLibFileFormatException

writeAsESOM

public static void writeAsESOM(SOMLibClassInformation classInfo,
                               String fileName)
                        throws IOException,
                               SOMLibFileFormatException
Writes the class information as ESOM cls file.

Throws:
IOException
SOMLibFileFormatException

writeAsSOMLib

public static void writeAsSOMLib(InputData data,
                                 String fileName)
                          throws IOException
Throws:
IOException

writeAsSOMLib

public static void writeAsSOMLib(InputData data,
                                 TemplateVector templateVector,
                                 SOMLibClassInformation classInformation,
                                 boolean tabSeparatedClassFile,
                                 String basicFileName)
                          throws IOException,
                                 SOMLibFileFormatException
Writes the class information to a file.

Throws:
IOException
SOMLibFileFormatException

writeAsSOMLib

public static void writeAsSOMLib(InputData data,
                                 TemplateVector templateVector,
                                 SOMLibClassInformation classInformation,
                                 String basicFileName)
                          throws IOException,
                                 SOMLibFileFormatException
Writes the class information to a file.

Throws:
IOException
SOMLibFileFormatException

writeAsSOMLib

public static void writeAsSOMLib(SOMLibClassInformation classInfo,
                                 String fileName)
                          throws IOException,
                                 SOMLibFileFormatException
Writes the class information to a file in SOMLib format.

Throws:
IOException
SOMLibFileFormatException

writeAsSOMLib

public static void writeAsSOMLib(HashMap<String,String> classInfo,
                                 HashSet<String> classNames,
                                 String fileName)
                          throws IOException,
                                 SOMLibFileFormatException
Writes the class information to a file in SOMLib format.

Throws:
IOException
SOMLibFileFormatException

writeAsSOMLib

public static void writeAsSOMLib(TemplateVector tv,
                                 String fileName)
                          throws IOException
Throws:
IOException

writeAsSOMPAK

public static void writeAsSOMPAK(InputData data,
                                 String fileName)
                          throws IOException
Writes input data in the SOMPAK format (see http://www.cis.hut.fi/projects/somtoolbox/package/docs2/som_read_data.html)

Throws:
IOException

writeAsWekaARFF

public static void writeAsWekaARFF(InputData data,
                                   String fileName,
                                   boolean writeInstanceNames,
                                   boolean skipInputsWithoutClass)
                            throws IOException,
                                   SOMToolboxException
Writes the data to Weka ARFF format.

Throws:
IOException
SOMToolboxException

getWekaClassHeader

public static String getWekaClassHeader(String[] classNames)

writeAsOrange

public static void writeAsOrange(InputData data,
                                 String fileName)
                          throws IOException
Writes input data in the tab-separated format used by the Orange data mining toolkit (see http://www.ailab.si/orange/)

Throws:
IOException

writeElementToFile

public static void writeElementToFile(PrintWriter writer,
                                      int i,
                                      TemplateVectorElement e)

writeHeaderToFile

public static void writeHeaderToFile(PrintWriter writer,
                                     int numVectors,
                                     int dim)
                              throws IOException
Throws:
IOException

writeInputDatumToFile

public static void writeInputDatumToFile(PrintWriter writer,
                                         InputDatum inputDatum)
                                  throws IOException
Throws:
IOException

writeInputDatumToFile

public static void writeInputDatumToFile(PrintWriter writer,
                                         String label,
                                         cern.colt.matrix.DoubleMatrix1D vector)
                                  throws IOException
Throws:
IOException

writeTempplateHeaderToFile

public static void writeTempplateHeaderToFile(PrintWriter writer,
                                              String fileName,
                                              int numVectors,
                                              int dim,
                                              int numInfo)
                                       throws IOException
Throws:
IOException

writeToFileTabSeparated

public static void writeToFileTabSeparated(SOMLibClassInformation classInfo,
                                           String fileName)
                                    throws IOException,
                                           SOMLibFileFormatException
Writes the class information to a tab-separated file.

Throws:
IOException
SOMLibFileFormatException