Пример #1
0
        public void evaluateError_2()
        {
            int N = 6;
            int D = 2;

            double[,] P = Matrix.Random(6, 6, new NormalDistribution());
            double[][] p = P.ToJagged();

            double[,] Y = Matrix.Random(6, 2, new NormalDistribution());
            double[][] y = Y.ToJagged();

            double expected = TSNEWrapper.evaluateError(P, Y, N, D);

            double actual = TSNE.evaluateError(p, y, N, D);

            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        public void evaluateError_1()
        {
            double perplexity = 0.5;
            double theta      = 0.5;
            int    N          = 6;
            int    K          = (int)(3 * perplexity);
            int    D          = 2;

            uint[]   row_P = Vector.Create(N + 1, new uint[] { 0, 1, 2, 3, 4, 5, 6 });
            uint[]   col_P = Vector.Create(N * K, new uint[] { 5, 3, 1, 1, 2, 1 });
            double[] val_P = Vector.Create(N * K, new double[]
            {
                0.99901046609114708,
                0.99901047304189827,
                0.99901046869768451,
                0.99901047304189827,
                0.99901046869768484,
                0.99901046869768451,
            });

            double[,] Y = Matrix.Random(6, 2, new NormalDistribution());
            double[][] y = Y.ToJagged();

            uint[]   expected_row = Vector.Create(row_P);
            uint[]   expected_col = Vector.Create(col_P);
            double[] expected_val = Vector.Create(val_P);
            double   expected     = TSNEWrapper.evaluateError(expected_row, expected_col, expected_val, Y, N, D, theta);

            int[]    actual_row = row_P.To <int[]>();
            int[]    actual_col = col_P.To <int[]>();
            double[] actual_val = (double[])val_P.Clone();
            double   actual     = TSNE.evaluateError(actual_row, actual_col, actual_val, y, N, D, theta);

            Assert.AreEqual(expected, actual);
            Assert.IsTrue(actual_col.IsEqual(expected_col));
            Assert.IsTrue(actual_row.IsEqual(expected_row));
            Assert.IsTrue(actual_val.IsEqual(expected_val));
        }