use of org.apache.ignite.ml.math.primitives.vector.impl.VectorizedViewMatrix in project ignite by apache.
the class CollectionsTest method test.
/**
*/
@Test
@SuppressWarnings("unchecked")
public void test() {
test(new VectorizedViewMatrix(new DenseMatrix(2, 2), 1, 1, 1, 1), new VectorizedViewMatrix(new DenseMatrix(3, 2), 2, 1, 1, 1));
specialTest(new ManhattanDistance(), new ManhattanDistance());
specialTest(new HammingDistance(), new HammingDistance());
specialTest(new EuclideanDistance(), new EuclideanDistance());
FeatureMetadata data = new FeatureMetadata("name2");
data.setName("name1");
test(data, new FeatureMetadata("name2"));
test(new DatasetRow<>(new DenseVector()), new DatasetRow<>(new DenseVector(1)));
test(new LabeledVector<>(new DenseVector(), null), new LabeledVector<>(new DenseVector(1), null));
test(new Dataset<DatasetRow<Vector>>(new DatasetRow[] {}, new FeatureMetadata[] {}), new Dataset<DatasetRow<Vector>>(new DatasetRow[] { new DatasetRow() }, new FeatureMetadata[] { new FeatureMetadata() }));
test(new LogisticRegressionModel(new DenseVector(), 1.0), new LogisticRegressionModel(new DenseVector(), 0.5));
test(new KMeansModelFormat(new Vector[] {}, new ManhattanDistance()), new KMeansModelFormat(new Vector[] {}, new HammingDistance()));
test(new KMeansModel(new Vector[] {}, new ManhattanDistance()), new KMeansModel(new Vector[] {}, new HammingDistance()));
test(new SVMLinearClassificationModel(null, 1.0), new SVMLinearClassificationModel(null, 0.5));
test(new ANNClassificationModel(new LabeledVectorSet<>(), new ANNClassificationTrainer.CentroidStat()), new ANNClassificationModel(new LabeledVectorSet<>(1, 1), new ANNClassificationTrainer.CentroidStat()));
test(new ANNModelFormat(1, new ManhattanDistance(), false, new LabeledVectorSet<>(), new ANNClassificationTrainer.CentroidStat()), new ANNModelFormat(2, new ManhattanDistance(), false, new LabeledVectorSet<>(), new ANNClassificationTrainer.CentroidStat()));
}
use of org.apache.ignite.ml.math.primitives.vector.impl.VectorizedViewMatrix in project ignite by apache.
the class ExternalizeTest method test.
/**
*/
@Test
@SuppressWarnings("unchecked")
public void test() {
externalizeTest(new DelegatingVector(new DenseVector(1)));
externalizeTest(new VectorizedViewMatrix(new DenseMatrix(2, 2), 1, 1, 1, 1));
externalizeTest(new ManhattanDistance());
externalizeTest(new HammingDistance());
externalizeTest(new EuclideanDistance());
externalizeTest(new FeatureMetadata());
externalizeTest(new VectorizedViewMatrix(new DenseMatrix(2, 2), 1, 1, 1, 1));
externalizeTest(new DatasetRow<>(new DenseVector()));
externalizeTest(new LabeledVector<>(new DenseVector(), null));
externalizeTest(new Dataset<DatasetRow<Vector>>(new DatasetRow[] {}, new FeatureMetadata[] {}));
}
use of org.apache.ignite.ml.math.primitives.vector.impl.VectorizedViewMatrix in project ignite by apache.
the class MatrixVectorViewTest method assertMatrixVectorView.
/**
*/
private void assertMatrixVectorView(Matrix parent, int row, int col, int rowStride, int colStride) {
VectorizedViewMatrix view = new VectorizedViewMatrix(parent, row, col, rowStride, colStride);
String desc = "parent [" + parent.rowSize() + "x" + parent.columnSize() + "], view [" + row + "x" + col + "], strides [" + rowStride + ", " + colStride + "]";
final int size = view.size();
final int sizeByRows = rowStride == 0 ? IMPOSSIBLE_SIZE : (parent.rowSize() - row) / rowStride;
final int sizeByCols = colStride == 0 ? IMPOSSIBLE_SIZE : (parent.columnSize() - col) / colStride;
assertTrue("Size " + size + " differs from expected for " + desc, size == sizeByRows || size == sizeByCols);
for (int idx = 0; idx < size; idx++) {
final int rowIdx = row + idx * rowStride;
final int colIdx = col + idx * colStride;
assertEquals(UNEXPECTED_VALUE + " at view index " + idx + desc, parent.get(rowIdx, colIdx), view.get(idx), 0d);
}
}
Aggregations