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

Create() private static method

private static Create ( int n1, int n2, int k, double &inputs, NaiveKNearestNeighbors &naive, KNearestNeighbors &normal, KNearestNeighbors &target ) : void
n1 int
n2 int
k int
inputs double
naive NaiveKNearestNeighbors
normal KNearestNeighbors
target KNearestNeighbors
return void
        private static void Create(int n1, int n2, int k, out double[][] inputs, out NaiveKNearestNeighbors naive, out KNearestNeighbors<double[]> normal, out KNearestNeighbors target)
        {
            int n = n1 + n2;

            double[][] gauss1 = MultivariateNormalDistribution.Generate(n1,
                mean: new double[] { 2, 1 },
                covariance: new double[,] 
                {
                    { 1, 0 },
                    { 0, 1 },
                });

            double[][] gauss2 = MultivariateNormalDistribution.Generate(n2,
                mean: new double[] { -1, 4 },
                covariance: new double[,] 
                {
                    { 2, 1 },
                    { 0, 3 },
                });

            inputs = gauss1.Stack(gauss2);
            int[] outputs = Matrix.Vector(n1, 0).Concatenate(Matrix.Vector(n2, +1));

            var idx = Vector.Sample(n1 + n2);
            inputs = inputs.Submatrix(idx);
            outputs = outputs.Submatrix(idx);

            naive = new NaiveKNearestNeighbors(k, inputs, outputs);
            normal = new KNearestNeighbors<double[]>(k, inputs, outputs, new Euclidean());
            target = new KNearestNeighbors(k, inputs, outputs);
        }