Package de.jungblut.math.sparse

Examples of de.jungblut.math.sparse.SparseDoubleRowMatrix


  }

  @Test
  public void testMultiHammingLoss() {
    SparseDoubleRowMatrix groundTruth = new SparseDoubleRowMatrix(
        new double[][] { { 1d, 0d }, { 0d, 1d } });

    SparseDoubleRowMatrix hypo = new SparseDoubleRowMatrix(new double[][] {
        { 1d, 0d }, { 0d, 0d } });

    HammingLossFunction fnc = new HammingLossFunction(0.5d);

    double err = fnc.calculateError(groundTruth, hypo);
View Full Code Here


  }

  @Test
  public void testSparseSerDe() throws Exception {
    SparseDoubleRowMatrix mat = new SparseDoubleRowMatrix(
        new DenseDoubleMatrix(new double[][] { { 1, 0, 3 }, { 0, 0, 0 },
            { 1, 0, 0 } }));

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(baos);

    MatrixWritable.writeSparseMatrix(mat, out);

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    DataInputStream in = new DataInputStream(bais);
    DoubleMatrix readMat = MatrixWritable.readSparseMatrix(in);

    assertEquals(0.0d, mat.subtract(readMat).sum(), 1e-4);

  }
View Full Code Here

            "There wasn't at least a single featurevector, or the two array didn't match in size.");
    this.classes = outcome[0].getDimension() == 1 ? 2 : outcome[0]
        .getDimension();
    DoubleMatrix mat = null;
    if (features[0].isSparse()) {
      mat = new SparseDoubleRowMatrix(features);
    } else {
      mat = new DenseDoubleMatrix(features);
    }
    ConditionalLikelihoodCostFunction func = new ConditionalLikelihoodCostFunction(
        mat, new DenseDoubleMatrix(outcome));
View Full Code Here

  }

  public DoubleVector predict(DoubleVector feature,
      DoubleVector[] featuresPerState) {
    return ViterbiUtils.decode(theta,
        new SparseDoubleRowMatrix(Collections.singletonList(feature)),
        new SparseDoubleRowMatrix(featuresPerState), classes).getRowVector(0);
  }
View Full Code Here

TOP

Related Classes of de.jungblut.math.sparse.SparseDoubleRowMatrix

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.