Accord.Tests.Statistics.LinearScalingFilterTest.ApplyTest C# (CSharp) Method

ApplyTest() private method

private ApplyTest ( ) : void
return void
        public void ApplyTest()
        {
            DataTable input = new DataTable("Sample data");
            input.Columns.Add("x", typeof(double));
            input.Columns.Add("y", typeof(double));
            input.Rows.Add(0.0, 0);
            input.Rows.Add(0.2, -20);
            input.Rows.Add(0.8, -80);
            input.Rows.Add(1.0, -100);

            DataTable expected = new DataTable("Sample data");
            expected.Columns.Add("x", typeof(double));
            expected.Columns.Add("y", typeof(double));
            expected.Rows.Add(0, 1);
            expected.Rows.Add(20, 0.8);
            expected.Rows.Add(80, 0.2);
            expected.Rows.Add(100, 0.0);


            
            LinearScaling target = new LinearScaling("x","y");
            target.Columns["x"].OutputRange = new DoubleRange(0, 100);
            target.Columns["y"].OutputRange = new DoubleRange(0, 1);


            target.Detect(input);

            DataTable actual = target.Apply(input);

            for (int i = 0; i < actual.Rows.Count; i++)
            {
                double ex = (double)expected.Rows[i][0];
                double ey = (double)expected.Rows[i][1];

                double ax = (double)actual.Rows[i][0];
                double ay = (double)actual.Rows[i][1];

                Assert.AreEqual(ex, ax);
                Assert.AreEqual(ey, ay);
            }
            
        }
    }
LinearScalingFilterTest