jml.data
Class Data

java.lang.Object
  extended by jml.data.Data

public class Data
extends java.lang.Object

All indices of docTermCountArray start from 1.


Constructor Summary
Data()
           
 
Method Summary
static org.apache.commons.math.linear.RealMatrix docTermCountArray2Matrix(java.util.ArrayList<java.util.TreeMap<java.lang.Integer,java.lang.Integer>> docTermCountArray)
           
static org.apache.commons.math.linear.RealMatrix loadDenseMatrix(java.lang.String dataMatrixFilePath)
          Read a dense matrix from a text file.
static org.apache.commons.math.linear.RealMatrix loadMatrix(java.lang.String dataMatrixFilePath)
          Read a matrix from a text file.
static org.apache.commons.math.linear.RealMatrix loadMatrixFromDocTermCountFile(java.lang.String docTermCountFilePath)
          Load a RealMatrix from a doc-term-count file located at String docTermCountFilePath.
static org.apache.commons.math.linear.RealMatrix loadSparseMatrix(java.lang.String dataMatrixFilePath)
          Load a RealMatrix from a text file located at String dataMatrixFilePath.
static void main(java.lang.String[] args)
           
static org.apache.commons.math.linear.RealMatrix mapArray2Matrix(java.util.ArrayList<java.util.TreeMap<java.lang.Integer,java.lang.Double>> featureArray)
           
static void saveDenseMatrix(java.lang.String dataMatrixFilePath, org.apache.commons.math.linear.RealMatrix A)
          Write a dense matrix into a text file.
static void saveMatrix(java.lang.String dataMatrixFilePath, org.apache.commons.math.linear.RealMatrix A)
          Write a matrix into a text file.
static void saveSparseMatrix(java.lang.String dataMatrixFilePath, org.apache.commons.math.linear.RealMatrix A)
          Write a sparse matrix into a text file.
static org.apache.commons.math.linear.RealMatrix TwoDimArray2Matrix(java.util.ArrayList<double[]> denseArr)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Data

public Data()
Method Detail

main

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

saveMatrix

public static void saveMatrix(java.lang.String dataMatrixFilePath,
                              org.apache.commons.math.linear.RealMatrix A)
Write a matrix into a text file. Sparseness will be automatically detected.

Parameters:
dataMatrixFilePath - file path to write a matrix into
A - a real matrix

loadMatrix

public static org.apache.commons.math.linear.RealMatrix loadMatrix(java.lang.String dataMatrixFilePath)
Read a matrix from a text file. Sparseness will be automatically detected.

Parameters:
dataMatrixFilePath - file path to read a matrix from
Returns:
a real matrix

saveSparseMatrix

public static void saveSparseMatrix(java.lang.String dataMatrixFilePath,
                                    org.apache.commons.math.linear.RealMatrix A)
Write a sparse matrix into a text file. Each line corresponds to a non-zero entry with the format "(%d, %d) %.8g".

Parameters:
dataMatrixFilePath - file path to write a sparse matrix into
A - a sparse matrix

loadMatrixFromDocTermCountFile

public static org.apache.commons.math.linear.RealMatrix loadMatrixFromDocTermCountFile(java.lang.String docTermCountFilePath)
Load a RealMatrix from a doc-term-count file located at String docTermCountFilePath.

Parameters:
docTermCountFilePath - a String specifying the location of the doc-term-count file holding matrix data. Each line is an entry with the format (sampleID,[whitespace]featureID):[whitespace]value". sampleID and featureID start from 1.
Returns:
a sparse matrix

loadSparseMatrix

public static org.apache.commons.math.linear.RealMatrix loadSparseMatrix(java.lang.String dataMatrixFilePath)
Load a RealMatrix from a text file located at String dataMatrixFilePath.

Parameters:
dataMatrixFilePath - a String specifying the location of the text file holding matrix data. Each line is an entry with the format (without double quotes) "(rowIdx,[whitespace]colIdx):[whitespace]value". rowIdx and colIdx start from 1 as in MATLAB.
Returns:
a sparse matrix

mapArray2Matrix

public static org.apache.commons.math.linear.RealMatrix mapArray2Matrix(java.util.ArrayList<java.util.TreeMap<java.lang.Integer,java.lang.Double>> featureArray)

saveDenseMatrix

public static void saveDenseMatrix(java.lang.String dataMatrixFilePath,
                                   org.apache.commons.math.linear.RealMatrix A)
Write a dense matrix into a text file. Each line corresponds to a row with the format "%.8g\t%.8g\t%.8g\t... \t%.8g".

Parameters:
dataMatrixFilePath - file path to write a dense matrix into
A - a dense matrix

loadDenseMatrix

public static org.apache.commons.math.linear.RealMatrix loadDenseMatrix(java.lang.String dataMatrixFilePath)
Read a dense matrix from a text file. Each line corresponds to a row with the format "%.8g\t%.8g\t%.8g\t... \t%.8g".

Parameters:
dataMatrixFilePath - file path to read a dense matrix from
Returns:
a dense matrix

TwoDimArray2Matrix

public static org.apache.commons.math.linear.RealMatrix TwoDimArray2Matrix(java.util.ArrayList<double[]> denseArr)

docTermCountArray2Matrix

public static org.apache.commons.math.linear.RealMatrix docTermCountArray2Matrix(java.util.ArrayList<java.util.TreeMap<java.lang.Integer,java.lang.Integer>> docTermCountArray)