Examples of zSum()


Examples of org.apache.mahout.math.Vector.zSum()

      weightsPerFeature = new RandomAccessSparseVector(instance.size(), instance.getNumNondefaultElements());
    }

    int label = index.get();
    weightsPerFeature.assign(instance, Functions.PLUS);
    weightsPerLabel.set(label, weightsPerLabel.get(label) + instance.zSum());
  }

  @Override
  protected void cleanup(Context ctx) throws IOException, InterruptedException {
    if (weightsPerFeature != null) {
View Full Code Here

Examples of org.apache.mahout.math.Vector.zSum()

    } else {
      Vector p = classify(data);
      if (actual > 0) {
        return Math.max(MIN_LOG_LIKELIHOOD, Math.log(p.get(actual - 1)));
      } else {
        return Math.max(MIN_LOG_LIKELIHOOD, Math.log1p(-p.zSum()));
      }
    }
  }
}
View Full Code Here

Examples of org.apache.mahout.math.Vector.zSum()

    Vector v = lr.classify(new DenseVector(new double[]{0, 0}));
    assertEquals(1 / 3.0, v.get(0), 1.0e-8);
    assertEquals(1 / 3.0, v.get(1), 1.0e-8);

    v = lr.classifyFull(new DenseVector(new double[]{0, 0}));
    assertEquals(1.0, v.zSum(), 1.0e-8);
    assertEquals(1 / 3.0, v.get(0), 1.0e-8);
    assertEquals(1 / 3.0, v.get(1), 1.0e-8);
    assertEquals(1 / 3.0, v.get(2), 1.0e-8);

    // weights for second vector component are still zero so all classifications are equally likely
View Full Code Here

Examples of org.apache.mahout.math.Vector.zSum()

  public double getAverageStd() {
    if (sumWeight == 0.0) {
      return 0.0;
    } else {
      Vector std = getStd();
      return std.zSum() / std.size();
    }
  }

  @Override
  public Vector getVariance() {
View Full Code Here

Examples of org.apache.mahout.math.Vector.zSum()

    w.addToVector("and", v3);
    w.addToVector("more", v3);
    assertEquals(0, v3.minus(v2).norm(1), 0);

    // moreover, the locations set in the unweighted case should be the same as in the weighted case
    assertEquals(v3.zSum(), v3.dot(v1), 0);
  }

  @Test
  public void testAsString() {
    Locale.setDefault(Locale.ENGLISH);
View Full Code Here

Examples of org.apache.mahout.math.Vector.zSum()

      List<VectorWritable> list = redWriter.getValue(key);
      assertEquals("One item in the list", 1, list.size());
      Vector item = list.get(0).get();
     
      // should only be one non-zero item
      assertTrue("One non-zero item in the array", Math.abs(item.zSum() + 0.48) < 0.01);
    }

  }
}
View Full Code Here

Examples of org.apache.mahout.math.Vector.zSum()

    } else {
      Vector p = classify(data);
      if (actual > 0) {
        return Math.max(-100.0, Math.log(p.get(actual - 1)));
      } else {
        return Math.max(-100.0, Math.log(1.0 - p.zSum()));
      }
    }
  }
}
View Full Code Here

Examples of org.apache.mahout.math.Vector.zSum()

    } else {
      int i = 0;
      for (Cluster model : models) {
        pdfs.set(i++, model.pdf(new VectorWritable(instance)));
      }
      return pdfs.assign(new TimesFunction(), 1.0 / pdfs.zSum());
    }
  }
 
  @Override
  public double classifyScalar(Vector instance) {
View Full Code Here

Examples of org.apache.mahout.matrix.Vector.zSum()

    mean = s1.divide(s0);
    // compute the average of the component stds
    if (s0 > 1) {
      Vector std = s2.times(s0).minus(s1.times(s1)).assign(
          new SquareRootFunction()).divide(s0);
      stdDev = std.zSum() / s1.size();
    } else {
      stdDev = Double.MIN_VALUE;
    }
  }
View Full Code Here

Examples of org.apache.mahout.matrix.Vector.zSum()

  /** @return the std */
  public double getStd() {
    Vector stds = pointSquaredTotal.times(getNumPoints()).minus(
          getPointTotal().times(getPointTotal())).assign(new SquareRootFunction())
          .divide(getNumPoints());
    return stds.zSum() / 2;
  }

}
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.