public void factorize(SparseMatrix matrix, int dimensions) { try { File mFile = File.createTempFile("octave-input", ".dat"); mFile.deleteOnExit(); MatrixIO.writeMatrix(matrix, mFile, Format.MATLAB_SPARSE); factorize(new MatrixFile(mFile, Format.MATLAB_SPARSE), dimensions); } catch (IOException ioe) { LOG.log(Level.SEVERE, "Converting to matlab file", ioe); } }
public void factorize(SparseMatrix matrix, int dimensions) { try { File mFile = File.createTempFile("matlab-input", ".dat"); MatrixIO.writeMatrix(matrix, mFile, Format.MATLAB_SPARSE); factorize(new MatrixFile(mFile, Format.MATLAB_SPARSE), dimensions); } catch (IOException ioe) { LOG.log(Level.SEVERE, "Converting to matlab file", ioe); } }
public void factorize(SparseMatrix matrix, int dimensions) { try { File mFile = File.createTempFile("matlab-input", ".dat"); MatrixIO.writeMatrix(matrix, mFile, Format.MATLAB_SPARSE); factorize(new MatrixFile(mFile, Format.MATLAB_SPARSE), dimensions); } catch (IOException ioe) { LOG.log(Level.SEVERE, "Converting to matlab file", ioe); } }
public void factorize(SparseMatrix matrix, int dimensions) { try { File mFile = File.createTempFile("octave-input", ".dat"); MatrixIO.writeMatrix(matrix, mFile, Format.MATLAB_SPARSE); factorize(new MatrixFile(mFile, Format.MATLAB_SPARSE), dimensions); } catch (IOException ioe) { LOG.log(Level.SEVERE, "Converting to matlab file", ioe); } }
/** * {@inheritDoc} */ public MatrixFile getMatrixFile() { return new MatrixFile(getFile(), getMatrixFormat()); }
/** * {@inheritDoc} */ public MatrixFile getMatrixFile() { return new MatrixFile(getFile(), getMatrixFormat()); }
/** * {@inheritDoc} */ public MatrixFile getMatrixFile() { return new MatrixFile(getFile(), getMatrixFormat()); }
/** * {@inheritDoc} */ public MatrixFile getMatrixFile() { return new MatrixFile(getFile(), getMatrixFormat()); }
/** * {@inheritDoc} */ public MatrixFile getMatrixFile() { return new MatrixFile(getFile(), getMatrixFormat()); }
/** * {@inheritDoc} */ public MatrixFile getMatrixFile() { return new MatrixFile(getFile(), getMatrixFormat()); }
/** * {@inheritDoc} */ public void factorize(SparseMatrix matrix, int dimensions) { try { File temp = File.createTempFile("svdlibc.svd.matrix", "dat"); temp.deleteOnExit(); MatrixIO.writeMatrix(matrix, temp, Format.SVDLIBC_SPARSE_TEXT); MatrixFile mFile = new MatrixFile(temp, Format.SVDLIBC_SPARSE_TEXT); factorize(mFile, dimensions); } catch (IOException ioe) { throw new IOError(ioe); } }
/** * {@inheritDoc} */ public MatrixFile getMatrixFile() { return new MatrixFile(getFile(), getMatrixFormat()); }
/** * {@inheritDoc} */ public MatrixFile getMatrixFile() { return new MatrixFile(getFile(), getMatrixFormat()); }
/** * {@inheritDoc} */ public void factorize(SparseMatrix matrix, int dimensions) { try { File temp = File.createTempFile("svdlibc.svd.matrix", "dat"); MatrixIO.writeMatrix(matrix, temp, Format.SVDLIBC_SPARSE_TEXT); MatrixFile mFile = new MatrixFile(temp, Format.SVDLIBC_SPARSE_TEXT); factorize(mFile, dimensions); } catch (IOException ioe) { throw new IOError(ioe); } }
MatrixIO.writeMatrix(affinityMatrix, affMatrixFile, MatrixIO.Format.MATLAB_SPARSE); return execute(m, new MatrixFile(affMatrixFile, MatrixIO.Format.MATLAB_SPARSE), dimensions);
MatrixIO.writeMatrix(affinityMatrix, affMatrixFile, MatrixIO.Format.MATLAB_SPARSE); return execute(m, new MatrixFile(affMatrixFile, MatrixIO.Format.MATLAB_SPARSE), dimensions);
/** * {@inheritDoc} */ public MatrixFile calculate(Matrix input) { try { File affMatrixFile = File.createTempFile("affinty-matrix",".dat"); PrintWriter affMatrixWriter = new PrintWriter(affMatrixFile); int rows = input.rows(); LOG.fine("Calculating the affinity matrix"); RowComparator rc = new RowComparator(); for (int i = 0; i < rows; ++i) { LOG.fine("computing affinity for row " + i); MultiMap<Double,Integer> neighborMap = rc.getMostSimilar( input, i, numNearestNeighbors, edgeSim); DoubleVector row = input.getRowVector(i); for (int n : neighborMap.values()) { double edgeWeight = kernelSim.sim( row, input.getRowVector(n)); affMatrixWriter.printf("%d %d %f\n", i+1 ,n+1, edgeWeight); } } // Finish writing the affinity matrix so it can be sent to matlab affMatrixWriter.close(); return new MatrixFile(affMatrixFile, MatrixIO.Format.MATLAB_SPARSE); } catch (IOException ioe) { throw new IOError(ioe); } }
/** * Projects the rows of the input matrix into a lower dimensional subspace * using the Locality Preserving Projection (LPP) algorithm and the affinity * matrix as a guide to locality. * * @param inputMatrix a matrix file whose rows will be projected * @param affinityMatrix a square matrix whose entries denote locality * between the rows of the inputMatrix. Note that this matrix's * dimensions must be equal to the number of rows in the input * matrix. * @param dimensions the number of dimensions into which the inputMatrix * should be projected * * @return a file containing the LPP-reduced data in {@code DENSE_TEXT} * format. * * @throws IOError if any exception occurrs during processing */ public static MatrixFile project(MatrixFile inputMatrix, MatrixFile affinityMatrix, int dimensions) { try { File outputFile = File.createTempFile("lcc-output-matrix", ".dat"); execute(inputMatrix.getFile(), affinityMatrix.getFile(), dimensions, outputFile); return new MatrixFile(outputFile, MatrixIO.Format.DENSE_TEXT); } catch (IOException ioe) { throw new IOError(ioe); } }
/** * Projects the rows of the input matrix into a lower dimensional subspace * using the Locality Preserving Projection (LPP) algorithm and the affinity * matrix as a guide to locality. * * @param inputMatrix a matrix file whose rows will be projected * @param affinityMatrix a square matrix whose entries denote locality * between the rows of the inputMatrix. Note that this matrix's * dimensions must be equal to the number of rows in the input * matrix. * @param dimensions the number of dimensions into which the inputMatrix * should be projected * * @return a file containing the LPP-reduced data in {@code DENSE_TEXT} * format. * * @throws IOError if any exception occurrs during processing */ public static MatrixFile project(MatrixFile inputMatrix, MatrixFile affinityMatrix, int dimensions) { try { File outputFile = File.createTempFile("lcc-output-matrix", ".dat"); execute(inputMatrix.getFile(), affinityMatrix.getFile(), dimensions, outputFile); return new MatrixFile(outputFile, MatrixIO.Format.DENSE_TEXT); } catch (IOException ioe) { throw new IOError(ioe); } }
return new MatrixFile( termDocumentMatrix, termDocumentMatrixBuilder.getMatrixFormat());