Java Code Examples for org.apache.mahout.math.Vector#zSum()

The following examples show how to use org.apache.mahout.math.Vector#zSum() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: 1000021_CDbwEvaluator_t.java    From coming with MIT License 6 votes vote down vote up
private void setStDev(int cI) {
   List<VectorWritable> repPts = representativePoints.get(cI);
   //if (repPts == null) {
   //  System.out.println();
   //}
   int s0 = 0;
   Vector s1 = null;
   Vector s2 = null;
   for (VectorWritable vw : repPts) {
     s0++;
     Vector v = vw.get();
     s1 = s1 == null ? v.clone() : s1.plus(v);
     s2 = s2 == null ? v.times(v) : s2.plus(v.times(v));
   }
  if (s0 > 1) {
   Vector std = s2.times(s0).minus(s1.times(s1)).assign(new SquareRootFunction()).divide(s0);
   double d = std.zSum() / std.size();
   //System.out.println("stDev[" + cI + "]=" + d);
   stDevs.put(cI, d);
 }
}
 
Example 2
Source File: 1000021_CDbwEvaluator_s.java    From coming with MIT License 6 votes vote down vote up
private void setStDev(int cI) {
  List<VectorWritable> repPts = representativePoints.get(cI);
  //if (repPts == null) {
  //  System.out.println();
  //}
  int s0 = 0;
  Vector s1 = null;
  Vector s2 = null;
  for (VectorWritable vw : repPts) {
    s0++;
    Vector v = vw.get();
    s1 = s1 == null ? v.clone() : s1.plus(v);
    s2 = s2 == null ? v.times(v) : s2.plus(v.times(v));
  }
  Vector std = s2.times(s0).minus(s1.times(s1)).assign(new SquareRootFunction()).divide(s0);
  double d = std.zSum() / std.size();
  //System.out.println("stDev[" + cI + "]=" + d);
  stDevs.put(cI, d);
}
 
Example 3
Source File: RidgeBinaryLogisticLoss.java    From pyramid with Apache License 2.0 5 votes vote down vote up
/**
 * dot product of a column vector and another vector
 * @param columnIndex the bias feature has index 0
 * @param vector
 * @return
 */
private double columnDot(int columnIndex, Vector vector){
    if (columnIndex==0){
        return vector.zSum();
    } else {
        return dataSet.getColumn(columnIndex-1).dot(vector);
    }
}