Package org.apache.mahout.math

Examples of org.apache.mahout.math.NamedVector


            IntWritable key = reader.getCurrentKey();
            int rowID = key.get();
            VectorWritable value = reader.getCurrentValue();
            Vector rowInfo = value.get();
            if (rowInfo instanceof NamedVector) {
                NamedVector nrowInfo = (NamedVector) rowInfo;
                rowID = Integer.parseInt(nrowInfo.getName());
            }
            for (Iterator<Vector.Element> itr = rowInfo.iterateNonZero(); itr.hasNext();) {
                Vector.Element elemInfo = itr.next();
                Tuple currElement = tupleFactory.newTuple(2);
                currElement.set(0, elemInfo.index());
View Full Code Here


        Vector currRowVector;
        if (dimensions == 0) {
            throw new IllegalArgumentException("Trying to create 0 dimension vector");
        }
        if (STORE_AS_DENSE) {
            currRowVector = new NamedVector(new DenseVector(dimensions), outputKey.toString());
        } else if (STORE_AS_SEQUENTIAL) {
            currRowVector = new NamedVector(new SequentialAccessSparseVector(dimensions, currRow.size()),
                    outputKey.toString());
        } else {
            currRowVector = new NamedVector(new RandomAccessSparseVector(dimensions, currRow.size()),
                    outputKey.toString());
        }
        for (int ii = 0; ii < currRow.size(); ii++) {
            Object o = currRow.get(ii);
            switch (currRow.getType(ii)) {
View Full Code Here

            DataBag rowInfoBag = bagFactory.newDefaultBag();
            IntWritable key = (IntWritable) reader.getCurrentKey();
            int clusterID = key.get();
            WeightedVectorWritable value = (WeightedVectorWritable) reader.getCurrentValue();
            Vector rowInfo = value.getVector();
            NamedVector nrowInfo = (NamedVector) rowInfo;
            int vectorID = Integer.parseInt(nrowInfo.getName());
            for (Iterator<Vector.Element> itr = rowInfo.iterateNonZero(); itr.hasNext();) {
                Vector.Element elemInfo = itr.next();
                Tuple currElement = tupleFactory.newTuple(2);
                currElement.set(0, elemInfo.index());
                currElement.set(1, elemInfo.get());
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.NamedVector

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.