Package edu.ucla.sspace.matrix

Examples of edu.ucla.sspace.matrix.MatrixFile


                coalsMatrixFile.deleteOnExit();
                MatrixIO.writeMatrix(finalCorrelation,
                                     coalsMatrixFile,
                                     Format.SVDLIBC_SPARSE_BINARY);

                MatrixFile processedSpace = new MatrixFile(
                        coalsMatrixFile, Format.SVDLIBC_SPARSE_BINARY);
                reducer.factorize(processedSpace, reducedDimensions);

                finalCorrelation = reducer.dataClasses();
            } catch (IOException ioe) {
View Full Code Here


     *        properties.
     */
    public void processSpace(Properties properties) {
        // Perform any optional transformations (e.g., tf-idf) on the
        // term-document matrix
        MatrixFile processedSpace = processSpace(transform);

        LoggerUtil.info(LOG, "reducing to %d dimensions", dimensions);

        // Compute the SVD on the term-document space
        reducer.factorize(processedSpace, dimensions);
View Full Code Here

            String transformClass =
                properties.getProperty(MATRIX_TRANSFORM_PROPERTY);
            if (transformClass != null)
                transform = ReflectionUtil.getObjectInstance(transformClass);

            MatrixFile transformedMatrix = processSpace(transform);

            // Set all of the default properties
            int dimensions = 300;

            // Then load any of the user-specified properties
            String dimensionsProp =
                properties.getProperty(LPSA_DIMENSIONS_PROPERTY);
            if (dimensionsProp != null) {
                try {
                    dimensions = Integer.parseInt(dimensionsProp);
                } catch (NumberFormatException nfe) {
                    throw new IllegalArgumentException(
                        LPSA_DIMENSIONS_PROPERTY + " is not an integer: " +
                        dimensionsProp);
                }
            }

            LoggerUtil.verbose(LOG, "reducing to %d dimensions", dimensions);

            Matrix termDocMatrix = MatrixIO.readMatrix(
                transformedMatrix.getFile(),
                transformedMatrix.getFormat(),
                Matrix.Type.SPARSE_IN_MEMORY, true);

            // Calculate the affinity matrix for the term-doc matrix
            MatrixFile affinityMatrix = affinityCreator.calculate(
                termDocMatrix);

            // Using the affinity matrix as a guide to locality, project the
            // co-occurrence matrix into the lower dimensional subspace
            wordSpace = LocalityPreservingProjection.project(
View Full Code Here

    }

    public Assignments cluster(Matrix matrix,
                               int numClusters,
                               Properties props) {
        MatrixFile affinityMatrix = creator.calculate(matrix);
        return linkCluster.cluster(affinityMatrix.load(), numClusters, props);
    }
View Full Code Here

        MatrixFile affinityMatrix = creator.calculate(matrix);
        return linkCluster.cluster(affinityMatrix.load(), numClusters, props);
    }

    public Assignments cluster(Matrix matrix, Properties props) {
        MatrixFile affinityMatrix = creator.calculate(matrix);
        return linkCluster.cluster(affinityMatrix.load(), props);
    }
View Full Code Here

        } catch (Throwable t) {
            t.printStackTrace();
        }

        // Calculate the affinity matrix for the cooccurrence matrix
        MatrixFile affinityMatrix = affinityCreator.calculate(
                cooccurrenceMatrix);
       
        // Using the affinity matrix as a guide to locality, project the
        // co-occurrence matrix into the lower dimensional subspace
        reduced = LocalityPreservingProjection.project(
View Full Code Here

        try {
            File rawTermDocMatrix =
                File.createTempFile("lra-term-document-matrix", ".dat");
            MatrixIO.writeMatrix(sparse_matrix, rawTermDocMatrix,
                                 MatrixIO.Format.SVDLIBC_SPARSE_TEXT);
            MatrixFile mFile = new MatrixFile(
                    rawTermDocMatrix, MatrixIO.Format.SVDLIBC_SPARSE_TEXT);
            reducer.factorize(mFile, dimensions);
            return reducer.dataClasses();
        } catch (IOException ioe){
            throw new IOError(ioe);
View Full Code Here

                                         Format format) {
        try {
            File mFile = File.createTempFile("TestSvdMatrix", "dat");
            mFile.deleteOnExit();
            MatrixIO.writeMatrix(matrix, mFile, format);
            reducer.factorize(new MatrixFile(mFile, format), 2);
        } catch (Exception ioe) {
            ioe.printStackTrace();
        }

            validateResults(reducer);
View Full Code Here

            String transformClass =
                properties.getProperty(MATRIX_TRANSFORM_PROPERTY);
            if (transformClass != null)
                transform = ReflectionUtil.getObjectInstance(
                        transformClass);
            MatrixFile processedSpace = super.processSpace(transform);
            System.out.printf("Matrix saved in %s as %s%n",
                              processedSpace.getFile(),
                              processedSpace.getFormat());
            wordSpace = MatrixIO.readMatrix(processedSpace.getFile(),
                                            processedSpace.getFormat());
            System.out.printf("loaded word space of %d x %d%n",
                              wordSpace.rows(), wordSpace.columns());
        } catch (IOException ioe) {
            throw new IOError(ioe);
        }
View Full Code Here

                LoggerUtil.verbose(
                        LOG, "transformed matrix to %s",
                        termDocumentMatrix.getAbsolutePath());
            }

            return new MatrixFile(
                    termDocumentMatrix,
                    termDocumentMatrixBuilder.getMatrixFormat());
        } catch (IOException ioe) {
            throw new IOError(ioe);
        }
View Full Code Here

TOP

Related Classes of edu.ucla.sspace.matrix.MatrixFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.