Accord.Tests.MachineLearning.KnnPerformanceTest.AccuracyTest1 C# (CSharp) Method

AccuracyTest1() private method

private AccuracyTest1 ( ) : void
return void
        public void AccuracyTest1()
        {
            int n1 = 5000;
            int n2 = 3000;
            int k = 15;

            double[][] inputs;
            NaiveKNearestNeighbors naive;
            KNearestNeighbors<double[]> normal;
            KNearestNeighbors target;
            Create(n1, n2, k, out inputs, out naive, out normal, out target);


            for (int i = 0; i < inputs.Length; i++)
            {
                double[][] expectedNN;
                int[] expectedLabels;

                expectedNN = naive.GetNearestNeighbors(inputs[i], out expectedLabels);

                double[][] normalNN;
                int[] normalLabels;

                normalNN = normal.GetNearestNeighbors(inputs[i], out normalLabels);

                double[][] targetNN;
                int[] targetLabels;

                targetNN = target.GetNearestNeighbors(inputs[i], out targetLabels);

                Assert.AreEqual(expectedNN.Length, normalNN.Length);
                Assert.AreEqual(expectedNN.Length, targetNN.Length);

                for (int j = 0; j < expectedNN.Length; j++)
                {
                    int ni = normalNN.IndexOf(expectedNN[j]);
                    Assert.AreEqual(expectedNN[j], normalNN[ni]);
                    Assert.AreEqual(expectedLabels[j], normalLabels[ni]);

                    int ti = targetNN.IndexOf(expectedNN[j]);
                    Assert.AreEqual(expectedNN[j], targetNN[ti]);
                    Assert.AreEqual(expectedLabels[j], targetLabels[ti]);
                }
            }
        }