Example usage for org.apache.mahout.math VectorWritable writeVector

List of usage examples for org.apache.mahout.math VectorWritable writeVector

Introduction

In this page you can find the example usage for org.apache.mahout.math VectorWritable writeVector.

Prototype

public static void writeVector(DataOutput out, Vector vector) throws IOException 

Source Link

Document

Write the vector to the output

Usage

From source file:at.illecker.hama.rootbeer.examples.matrixmultiplication.compositeinput.util.MatrixRowMessage.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(rowIndex);
    VectorWritable.writeVector(out, rowValues.get());
}

From source file:com.cloudera.knittingboar.sgd.ParallelOnlineLogisticRegression.java

License:Apache License

/**
 * TODO - add something in to write the gamma to the output stream -- do we
 * need to save gamma?//from  w  ww.j a  va 2  s.  co  m
 */
@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(WRITABLE_VERSION);
    out.writeDouble(learningRate);
    out.writeDouble(decayFactor);
    out.writeInt(stepOffset);
    out.writeInt(step);
    out.writeDouble(forgettingExponent);
    out.writeInt(perTermAnnealingOffset);
    out.writeInt(numCategories);
    MatrixWritable.writeMatrix(out, beta);
    PolymorphicWritable.write(out, prior);
    VectorWritable.writeVector(out, updateCounts);
    VectorWritable.writeVector(out, updateSteps);

}

From source file:com.netease.news.classifier.naivebayes.NaiveBayesModel.java

License:Apache License

public void serialize(Path output, Configuration conf) throws IOException {
    FileSystem fs = output.getFileSystem(conf);
    FSDataOutputStream out = fs.create(new Path(output, "naiveBayesModel.bin"));
    try {//from w  w  w .  j a v a 2s .  co  m
        out.writeFloat(alphaI);
        VectorWritable.writeVector(out, weightsPerFeature);
        VectorWritable.writeVector(out, weightsPerLabel);
        VectorWritable.writeVector(out, perlabelThetaNormalizer);
        for (int row = 0; row < weightsPerLabelAndFeature.numRows(); row++) {
            VectorWritable.writeVector(out, weightsPerLabelAndFeature.viewRow(row));
        }
    } finally {
        Closeables.close(out, false);
    }
}