org.apache.mahout.math.WeightedVector.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中org.apache.mahout.math.WeightedVector.<init>()方法的一些代码示例,展示了WeightedVector.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeightedVector.<init>()方法的具体详情如下:
包路径:org.apache.mahout.math.WeightedVector
类名称:WeightedVector
方法名:<init>

WeightedVector.<init>介绍

暂无

代码示例

代码示例来源:origin: apache/mahout

public static WeightedVector project(Vector v, Vector projection, int index) {
 return new WeightedVector(v, projection, index);
}

代码示例来源:origin: apache/mahout

@Override
public Vector like() {
 return new WeightedVector(getVector().like(), weight, index);
}

代码示例来源:origin: apache/mahout

@Override
 Vector generateTestVector(int cardinality) {
  return new WeightedVector(new DenseVector(cardinality), 3.14, 53);
 }
}

代码示例来源:origin: apache/mahout

@Override
public Centroid vectorToTest(int size) {
 return new Centroid(new WeightedVector(new DenseVector(size), 3.15, 51));
}

代码示例来源:origin: apache/mahout

@Override
public Vector vectorToTest(int size) {
 return new WeightedVector(new DenseVector(size), 4.52, 345);
}

代码示例来源:origin: apache/mahout

@Override
 Vector generateTestVector(int cardinality) {
  return new Centroid(new WeightedVector(new DenseVector(cardinality), 3.14, 53));
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testOrdering() {
 WeightedVector v1 = new WeightedVector(new DenseVector(new double[]{1, 2, 3}), 5.41, 31);
 WeightedVector v2 = new WeightedVector(new DenseVector(new double[]{1, 2, 3}), 5.00, 31);
 WeightedVector v3 = new WeightedVector(new DenseVector(new double[]{1, 3, 3}), 5.00, 31);
 WeightedVector v4 = v1.clone();
 WeightedVectorComparator comparator = new WeightedVectorComparator();
 assertTrue(comparator.compare(v1, v2) > 0);
 assertTrue(comparator.compare(v3, v1) < 0);
 assertTrue(comparator.compare(v3, v2) > 0);
 assertEquals(0, comparator.compare(v4, v1));
 assertEquals(0, comparator.compare(v1, v1));
}

代码示例来源:origin: apache/mahout

@Test
public void testProjection() {
 Vector v1 = new DenseVector(10).assign(Functions.random());
 WeightedVector v2 = new WeightedVector(v1, v1, 31);
 assertEquals(v1.dot(v1), v2.getWeight(), 1.0e-13);
 assertEquals(31, v2.getIndex());
 Matrix y = new DenseMatrix(10, 4).assign(Functions.random());
 Matrix q = new QRDecomposition(y.viewPart(0, 10, 0, 3)).getQ();
 Vector nullSpace = y.viewColumn(3).minus(q.times(q.transpose().times(y.viewColumn(3))));
 WeightedVector v3 = new WeightedVector(q.viewColumn(0).plus(q.viewColumn(1)), nullSpace, 1);
 assertEquals(0, v3.getWeight(), 1.0e-13);
 Vector qx = q.viewColumn(0).plus(q.viewColumn(1)).normalize();
 WeightedVector v4 = new WeightedVector(qx, q.viewColumn(0), 2);
 assertEquals(Math.sqrt(0.5), v4.getWeight(), 1.0e-13);
 WeightedVector v5 = WeightedVector.project(q.viewColumn(0), qx);
 assertEquals(Math.sqrt(0.5), v5.getWeight(), 1.0e-13);
}

代码示例来源:origin: org.apache.mahout/mahout-math

public static WeightedVector project(Vector v, Vector projection, int index) {
 return new WeightedVector(v, projection, index);
}

代码示例来源:origin: org.apache.mahout/mahout-math

@Override
public Vector like() {
 return new WeightedVector(getVector().like(), weight, index);
}

代码示例来源:origin: org.apache.mahout/mahout-mr

public void addAllMatrixSlicesAsWeightedVectors(Iterable<MatrixSlice> data) {
 for (MatrixSlice slice : data) {
  add(new WeightedVector(slice.vector(), 1, slice.index()));
 }
}

代码示例来源:origin: org.apache.mahout/mahout-core

public void addAllMatrixSlicesAsWeightedVectors(Iterable<MatrixSlice> data) {
 for (MatrixSlice slice : data) {
  add(new WeightedVector(slice.vector(), 1, slice.index()));
 }
}

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

public void addAllMatrixSlicesAsWeightedVectors(Iterable<MatrixSlice> data) {
 for (MatrixSlice slice : data) {
  add(new WeightedVector(slice.vector(), 1, slice.index()));
 }
}

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

private static List<? extends WeightedVector> cubishTestData(double radius) {
  List<WeightedVector> data = Lists.newArrayListWithCapacity(K1 + 5000);
  int row = 0;

  MultiNormal g = new MultiNormal(radius, new ConstantVector(0, 10));
  for (int i = 0; i < K1; i++) {
   data.add(new WeightedVector(g.sample(), 1, row++));
  }

  for (int i = 0; i < 5; i++) {
   Vector m = new DenseVector(10);
   m.set(i, 6); // This was originally i == 0 ? 6 : 6 which can't be right
   MultiNormal gx = new MultiNormal(radius, m);
   for (int j = 0; j < 1000; j++) {
    data.add(new WeightedVector(gx.sample(), 1, row++));
   }
  }
  return data;
 }
}

代码示例来源:origin: tdunning/anomaly-detection

for (int i = 0; i < SAMPLES; i++) {
  int offset = i * STEP;
  WeightedVector row = new WeightedVector(new DenseVector(WINDOW), 1, i);
  row.assign(trace.viewPart(offset, WINDOW));
  row.assign(window, Functions.MULT);
  for (int i = 0; i + WINDOW < trace.size(); i += WINDOW / 2) {
    WeightedVector row = new WeightedVector(new DenseVector(WINDOW), 1, i);
    row.assign(trace.viewPart(i, WINDOW));
    row.assign(window, Functions.MULT);

相关文章