@Test public void testDenseVectorRowInput(){ Vector vec = DenseVector.rand(10); EuclideanDistance distance = new EuclideanDistance(); FastDistanceVectorData vectorData = distance.prepareVectorData(Row.of(vec, 0, "a"), 0, 1, 2); assertVectorInput(vectorData, vec, Row.of(0, "a")); }
public FastDistanceVectorData prepareVectorData(Row row, int vectorIdx, int... keepIdxs) { return prepareVectorData(Tuple2.of(VectorUtil.getVector(row.getField(vectorIdx)), TableUtil.getRow(row, keepIdxs))); }
FastDistance implements ContinuousDistance { public FastDistanceVectorData prepareVectorData(Row row, int vectorIdx, int... keepIdxs) { return prepareVectorData(Tuple2.of(VectorUtil.getVector(row.getField(vectorIdx)), TableUtil.getRow(row, keepIdxs))); } }
FastDistance implements ContinuousDistance { public FastDistanceVectorData prepareVectorData(Row row, int vectorIdx, int... keepIdxs) { return prepareVectorData(Tuple2.of(VectorUtil.getVector(row.getField(vectorIdx)), TableUtil.getRow(row, keepIdxs))); }  }
FastDistance implements ContinuousDistance { public FastDistanceVectorData prepareVectorData(Row row, int vectorIdx, int... keepIdxs) { return prepareVectorData(Tuple2.of(VectorUtil.getVector(row.getField(vectorIdx)), TableUtil.getRow(row, keepIdxs))); }  List<FastDistanceData> prepareMatrixData(Iterable<Row> rows, int vectorIdx, int... keepIdxs); FastDistanceVectorData prepareVectorData(Row row, int vectorIdx, int... keepIdxs); List<FastDistanceData> prepareMatrixData(Iterable<Tuple2<Vector, Row>> tuples); FastDistanceVectorData prepareVectorData(Tuple2<Vector, Row> tuple); DenseMatrix calc(FastDistanceData left, FastDistanceData right); DenseMatrix calc(FastDistanceData left, FastDistanceData right, DenseMatrix res); abstract void updateLabel(FastDistanceData data); }
FastDistance implements ContinuousDistance { public FastDistanceVectorData prepareVectorData(Row row, int vectorIdx, int... keepIdxs) { return prepareVectorData(Tuple2.of(VectorUtil.getVector(row.getField(vectorIdx)), TableUtil.getRow(row, keepIdxs))); }  List<FastDistanceData> prepareMatrixData(Iterable<Row> rows, int vectorIdx, int... keepIdxs); FastDistanceVectorData prepareVectorData(Row row, int vectorIdx, int... keepIdxs); List<FastDistanceData> prepareMatrixData(Iterable<Tuple2<Vector, Row>> tuples); FastDistanceVectorData prepareVectorData(Tuple2<Vector, Row> tuple); DenseMatrix calc(FastDistanceData left, FastDistanceData right); DenseMatrix calc(FastDistanceData left, FastDistanceData right, DenseMatrix res); abstract void updateLabel(FastDistanceData data);  }